diff options
Diffstat (limited to 'sources/pyside2/doc/codesnippets/examples')
38 files changed, 0 insertions, 4263 deletions
diff --git a/sources/pyside2/doc/codesnippets/examples/dbus/example-client.py b/sources/pyside2/doc/codesnippets/examples/dbus/example-client.py deleted file mode 100755 index 52ad7335a..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dbus/example-client.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the documentation of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## # Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## # Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## # Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################# - -# -*- coding: utf-8 -*- - -# DBUS Client using PySide integration - -import sys -from traceback import print_exc - -# import python dbus module -import dbus -# import python dbus GLib mainloop support -import dbus.mainloop.glib -# import QtCore -from PySide2.QtCore import * - -# signal handler -def button_clicked(): - print "button clicked" - -# main function -if __name__ == '__main__': - - # Enable glib main loop support - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - # Get the session bus - bus = dbus.SessionBus() - - try: - # Get the remote object - remote_object = bus.get_object("com.example.SampleService", - "/DBusWidget") - # Get the remote interface for the remote object - iface = dbus.Interface(remote_object, "com.example.SampleWidget") - except dbus.DBusException: - print_exc() - sys.exit(1) - - # Start the application - app = QCoreApplication([]) - - # Call some methods of the remote interface - iface.show() - iface.setText("Emit signal") - # connect the DBus signal clicked to the function button_clicked - iface.connect_to_signal("clicked", button_clicked) - iface.connect_to_signal("lastWindowClosed", app.quit) - - # enter in the main loop - app.exec_() diff --git a/sources/pyside2/doc/codesnippets/examples/dbus/example-server.py b/sources/pyside2/doc/codesnippets/examples/dbus/example-server.py deleted file mode 100755 index c42b8697c..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dbus/example-server.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the documentation of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## # Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## # Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## # Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################# - -# -*- coding: utf-8 -*- - -# DBUS Server Example of use PySide with PyDBus library - -import dbus -import dbus.service -import dbus.mainloop.glib -import random - -from PySide2.QtCore import * -from PySide2.QtGui import QPushButton, QApplication - -# The adaptor, MUST inherit dbus.service.Object -class DBusWidget(dbus.service.Object): - def __init__(self, name, session): - # export this object to dbus - dbus.service.Object.__init__(self, name, session) - - # create a simple widget - self.widget = QPushButton() - self.widget.resize(200, 50) - - # To export a Qt signal as a DBus-signal, you need to connect it to a method in this class. - # The method MUST have the signal annotation, so python-dbus will export it as a dbus-signal - QObject.connect(self.widget, SIGNAL("clicked()"), self.clicked) - QObject.connect(QApplication.instance(), SIGNAL("lastWindowClosed()"), self.lastWindowClosed) - - # You can export methods to dbus like you do in python-dbus. - @dbus.service.method("com.example.SampleWidget", in_signature='', out_signature='') - def show(self): - self.widget.show() - - # Another method... now with a parameter - @dbus.service.method("com.example.SampleWidget", in_signature='s', out_signature='') - def setText(self, value): - self.widget.setText(value) - - # Another one... - @dbus.service.method("com.example.SampleWidget", in_signature='', out_signature='') - def exit(self): - qApp().quit() - - # A signal that will be exported to dbus - @dbus.service.signal("com.example.SampleWidget", signature='') - def clicked(self): - pass - - # Another signal that will be exported to dbus - @dbus.service.signal("com.example.SampleWidget", signature='') - def lastWindowClosed(self): - pass - - -if __name__ == '__main__': - app = QApplication([]) - # Use qt/glib mainloop integration to get dbus mainloop working - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - - session_bus = dbus.SessionBus() - # Export the service - name = dbus.service.BusName("com.example.SampleService", session_bus) - # Export the object - widget = DBusWidget(session_bus, '/DBusWidget') - - print "Running example service." - app.exec_() - diff --git a/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugin.cpp b/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugin.cpp deleted file mode 100644 index 4b8b9234f..000000000 --- a/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugin.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -class TimeModel (QObject): - hour = Property(int, getHour, notify = timeChanged) - minute = Property(int, getMinute, notify = timeChanged) -//![0] - -//![plugin] -class QExampleQmlPlugin (QDeclarativeExtensionPlugin): - - def registerTypes(self, uri): - assert(uri == "com.nokia.TimeExample") - qmlRegisterType(TimeModel, uri, 1, 0, "Time") -//![plugin] - -//![export] -# This isn't supported by PySide yet. -# Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin); -//![export] diff --git a/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugins.qml b/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugins.qml deleted file mode 100644 index 415531885..000000000 --- a/sources/pyside2/doc/codesnippets/examples/declarative/cppextensions/plugins/plugins.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import com.nokia.TimeExample 1.0 // import types from the plugin - -Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) - - Time { // this class is defined in C++ (plugin.cpp) - id: time - } - - hours: time.hour - minutes: time.minute -} -//![0] diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp deleted file mode 100644 index 897410ed7..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] //! [1] -def __init__(self, parent): - QWizard.__init__(self, parent): - self.addPage(IntroPage()) - self.addPage(ClassInfoPage()) - self.addPage(CodeStylePage()) - self.addPage(OutputFilesPage()) - self.addPage(ConclusionPage()) -//! [0] - - self.setPixmap(QWizard.BannerPixmap, QPixmap(":/images/banner.png")) - self.setPixmap(QWizard.BackgroundPixmap, QPixmap(":/images/background.png")) - - self.setWindowTitle(self.tr("Class Wizard")) -//! [2] - -//! [1] //! [2] - -//! [3] -def accept(self): -//! [3] //! [4] - className = self.field("className") - baseClass = self.field("baseClass") - macroName = self.field("macroName") - baseInclude = self.field("baseInclude") - - outputDir = self.field("outputDir") - header = self.field("header") - implementation = self.field("implementation") -//! [4] - -... - -//! [5] - QDialog.accept(self) -//! [5] //! [6] -} -//! [6] - -//! [7] -class IntroPage (QWizardPage): - - def __init__(self, parent): - QWizardPage.__init__(self, parent) - - self.setTitle(tr("Introduction")) - self.setPixmap(QWizard.WatermarkPixmap, QPixmap(":/images/watermark1.png")) - - label = QLabel(self.tr("This wizard will generate a skeleton C++ class " \ - "definition, including a few functions. You simply " \ - "need to specify the class name and set a few " \ - "options to produce a header file and an " \ - "implementation file for your new C++ class.")) - label.setWordWrap(True) - - layout = QVBoxLayout() - layout.addWidget(label) - self.setLayout(layout) -} -//! [7] - -//! [8] //! [9] -class ClassInfoPage(QWizardPage): - - def __init__(self, parent): - QWizardPage.__init__(self, parent) -//! [8] - self.setTitle(self.tr("Class Information")) - self.setSubTitle(self.tr("Specify basic information about the class for which you " \ - "want to generate skeleton source code files.")) - self.setPixmap(QWizard.LogoPixmap, QPixmap(":/images/logo1.png")) - -//! [10] - classNameLabel = QLabel(self.tr("&Class name:")) - classNameLineEdit = QLineEdit() - classNameLabel.setBuddy(classNameLineEdit) - - baseClassLabel = QLabel(self.tr("B&ase class:")) - baseClassLineEdit = QLineEdit() - baseClassLabel.setBuddy(baseClassLineEdit) - - qobjectMacroCheckBox = QCheckBox(self.tr("Generate Q_OBJECT ¯o")) - -//! [10] - groupBox = QGroupBox(self.tr("C&onstructor")) -//! [9] - - qobjectCtorRadioButton = QRadioButton(self.tr("&QObject-style constructor")) - qwidgetCtorRadioButton = QRadioButton(self.tr("Q&Widget-style constructor")) - defaultCtorRadioButton = QRadioButton(self.tr("&Default constructor")) - copyCtorCheckBox = QCheckBox(self.tr("&Generate copy constructor and operator=")) - - defaultCtorRadioButton.setChecked(True) - - self.connect(defaultCtorRadioButton, SIGNAL("toggled(bool)"), - copyCtorCheckBox, SLOT("setEnabled(bool)")) - -//! [11] //! [12] - registerField("className*", classNameLineEdit) - registerField("baseClass", baseClassLineEdit) - registerField("qobjectMacro", qobjectMacroCheckBox) -//! [11] - registerField("qobjectCtor", qobjectCtorRadioButton) - registerField("qwidgetCtor", qwidgetCtorRadioButton) - registerField("defaultCtor", defaultCtorRadioButton) - registerField("copyCtor", copyCtorCheckBox) - - groupBoxLayout = QVBoxLayout() -//! [12] - groupBoxLayout.addWidget(qobjectCtorRadioButton) - groupBoxLayout.addWidget(qwidgetCtorRadioButton) - groupBoxLayout.addWidget(defaultCtorRadioButton) - groupBoxLayout.addWidget(copyCtorCheckBox) - groupBox.setLayout(groupBoxLayout) - - layout = QGridLayout() - layout.addWidget(classNameLabel, 0, 0) - layout.addWidget(classNameLineEdit, 0, 1) - layout.addWidget(baseClassLabel, 1, 0) - layout.addWidget(baseClassLineEdit, 1, 1) - layout.addWidget(qobjectMacroCheckBox, 2, 0, 1, 2) - layout.addWidget(groupBox, 3, 0, 1, 2) - self.setLayout(layout) -//! [13] - -//! [13] - -//! [14] -class CodeStylePage(QWizardPage): - - def __init__(self, parent): - QWizardPage.__init__(self, parent) - self.setTitle(tr("Code Style Options")) - self.setSubTitle(tr("Choose the formatting of the generated code.")) - self.setPixmap(QWizard.LogoPixmap, QPixmap(":/images/logo2.png")) - - commentCheckBox = QCheckBox(self.tr("&Start generated files with a comment")) -//! [14] - commentCheckBox.setChecked(True) - - protectCheckBox = QCheckBox(self.tr("&Protect header file against multiple " \ - "inclusions")) - protectCheckBox.setChecked(True) - - macroNameLabel = QLabel(self.tr("&Macro name:")) - macroNameLineEdit = QLineEdit() - macroNameLabel.setBuddy(macroNameLineEdit) - - includeBaseCheckBox = QCheckBox(self.tr("&Include base class definition")) - baseIncludeLabel = QLabel(self.tr("Base class include:")) - baseIncludeLineEdit = QLineEdit() - baseIncludeLabel.setBuddy(baseIncludeLineEdit) - - self.connect(protectCheckBox, SIGNAL("toggled(bool)"), - macroNameLabel, SLOT("setEnabled(bool)")) - self.connect(protectCheckBox, SIGNAL("toggled(bool)"), - macroNameLineEdit, SLOT("setEnabled(bool)")) - self.connect(includeBaseCheckBox, SIGNAL("toggled(bool)"), - baseIncludeLabel, SLOT("setEnabled(bool)")) - self.connect(includeBaseCheckBox, SIGNAL(toggled(bool)), - baseIncludeLineEdit, SLOT("setEnabled(bool)")) - - self.registerField("comment", commentCheckBox) - self.registerField("protect", protectCheckBox) - self.registerField("macroName", macroNameLineEdit) - self.registerField("includeBase", includeBaseCheckBox) - self.registerField("baseInclude", baseIncludeLineEdit) - - layout = QGridLayout() - layout.setColumnMinimumWidth(0, 20) - layout.addWidget(commentCheckBox, 0, 0, 1, 3) - layout.addWidget(protectCheckBox, 1, 0, 1, 3) - layout.addWidget(macroNameLabel, 2, 1) - layout.addWidget(macroNameLineEdit, 2, 2) - layout.addWidget(includeBaseCheckBox, 3, 0, 1, 3) - layout.addWidget(baseIncludeLabel, 4, 1) - layout.addWidget(baseIncludeLineEdit, 4, 2) -//! [15] - self.setLayout(layout) -} -//! [15] - -//! [16] - def initializePage(self): - className = self.field("className") - self.macroNameLineEdit.setText(className.upper() + "_H") - - baseClass = self.field("baseClass") - - self.includeBaseCheckBox.setChecked(len(baseClass)) - self.includeBaseCheckBox.setEnabled(len(baseClass)) - self.baseIncludeLabel.setEnabled(len(baseClass)) - self.baseIncludeLineEdit.setEnabled(len(baseClass)) - - if not baseClass: - self.baseIncludeLineEdit.clear() - elsif QRegExp("Q[A-Z].*").exactMatch(baseClass): - baseIncludeLineEdit.setText("<" + baseClass + ">") - else: - baseIncludeLineEdit.setText("\"" + baseClass.lower() + ".h\"") -//! [16] - -//! [17] - def initializePage(self): - className = field("className") - self.headerLineEdit.setText(className.lower() + ".h") - self.implementationLineEdit.setText(className.lower() + ".cpp") - self.outputDirLineEdit.setText(QDir.convertSeparators(QDir.tempPath())) -//! [17] diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc deleted file mode 100644 index 41a5ddc7d..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/classwizard.qrc +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>images/background.png</file> - <file>images/banner.png</file> - <file>images/logo1.png</file> - <file>images/logo2.png</file> - <file>images/logo3.png</file> - <file>images/watermark1.png</file> - <file>images/watermark2.png</file> -</qresource> -</RCC> diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/background.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/background.png Binary files differdeleted file mode 100644 index 44c7badb8..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/background.png +++ /dev/null diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/banner.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/banner.png Binary files differdeleted file mode 100644 index 3169152b8..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/banner.png +++ /dev/null diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo1.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo1.png Binary files differdeleted file mode 100644 index f9b594aaf..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo1.png +++ /dev/null diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo2.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo2.png Binary files differdeleted file mode 100644 index 5dcbd4669..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo2.png +++ /dev/null diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo3.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo3.png Binary files differdeleted file mode 100644 index 9fd3ea235..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/logo3.png +++ /dev/null diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark1.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark1.png Binary files differdeleted file mode 100644 index 0091f5c17..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark1.png +++ /dev/null diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark2.png b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark2.png Binary files differdeleted file mode 100644 index 3b88f2e36..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/images/watermark2.png +++ /dev/null diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/extension/finddialog.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/extension/finddialog.cpp deleted file mode 100644 index a8496f4c8..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/extension/finddialog.cpp +++ /dev/null @@ -1,119 +0,0 @@ -############################################################################ -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the examples of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################ - - -from PySide2.QtGui import * - -//! [0] -def __init__(self, parent): - QDialog.__init__(self, parent) - label = QLabel(self.tr("Find &what:")) - lineEdit = QLineEdit() - label.setBuddy(lineEdit) - - caseCheckBox = QCheckBox(self.tr("Match &case")) - fromStartCheckBox = QCheckBox(self.tr("Search from &start")) - fromStartCheckBox.setChecked(True) - -//! [1] - findButton = QPushButton(self.tr("&Find")) - findButton.setDefault(True) - - moreButton = QPushButton(self.tr("&More")) - moreButton.setCheckable(True) -//! [0] - moreButton.setAutoDefault(False) - - buttonBox = QDialogButtonBox(Qt.Vertical) - buttonBox.addButton(findButton, QDialogButtonBox.ActionRole) - buttonBox.addButton(moreButton, QDialogButtonBox.ActionRole) -//! [1] - -//! [2] - extension = QWidget() - - wholeWordsCheckBox = QCheckBox(self.tr("&Whole words")) - backwardCheckBox = QCheckBox(self.tr("Search &backward")) - searchSelectionCheckBox = QCheckBox(self.tr("Search se&lection")) -//! [2] - -//! [3] - connect(moreButton, SIGNAL("toggled(bool)"), extension, SLOT("setVisible(bool)")) - - extensionLayout = QVBoxLayout() - extensionLayout.setMargin(0) - extensionLayout.addWidget(wholeWordsCheckBox) - extensionLayout.addWidget(backwardCheckBox) - extensionLayout.addWidget(searchSelectionCheckBox) - extension.setLayout(extensionLayout) -//! [3] - -//! [4] - topLeftLayout = QHBoxLayout() - topLeftLayout.addWidget(label) - topLeftLayout.addWidget(lineEdit) - - leftLayout = QVBoxLayout() - leftLayout.addLayout(topLeftLayout) - leftLayout.addWidget(caseCheckBox) - leftLayout.addWidget(fromStartCheckBox) - leftLayout.addSself.tretch(1) - - mainLayout = QGridLayout() - mainLayout.setSizeConsself.traint(QLayout.SetFixedSize) - mainLayout.addLayout(leftLayout, 0, 0) - mainLayout.addWidget(buttonBox, 0, 1) - mainLayout.addWidget(extension, 1, 0, 1, 2) - setLayout(mainLayout) - - setWindowTitle(self.tr("Extension")) -//! [4] //! [5] - extension.hide() -//! [5] diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/logo.png b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/logo.png Binary files differdeleted file mode 100644 index 56f17a3e5..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/logo.png +++ /dev/null diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/watermark.png b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/watermark.png Binary files differdeleted file mode 100644 index 124a05068..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/images/watermark.png +++ /dev/null diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h deleted file mode 100644 index f0be5fa60..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.h +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LICENSEWIZARD_H -#define LICENSEWIZARD_H - -#include <QWizard> - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QLabel; -class QLineEdit; -class QRadioButton; -QT_END_NAMESPACE - -//! [0] //! [1] -class LicenseWizard (QWizard): -//! [0] -//! [2] - Page_Intro = 1 - Page_Evaluate = 2 - Page_Register = 3 - Page_Details = 4 - Page_Conclusion = 5 -//! [2] - - def __init__(self, parent): - ... - - def showHelp(self): - ... -//! [3] - -//! [1] //! [3] - -//! [4] -class IntroPage : public QWizardPage -{ - Q_OBJECT - -public: - IntroPage(QWidget *parent = 0); - - int nextId() const; - -private: - QLabel *topLabel; - QRadioButton *registerRadioButton; - QRadioButton *evaluateRadioButton; -}; -//! [4] - -//! [5] -class EvaluatePage : public QWizardPage -{ - Q_OBJECT - -public: - EvaluatePage(QWidget *parent = 0); - - int nextId() const; - -private: - QLabel *nameLabel; - QLabel *emailLabel; - QLineEdit *nameLineEdit; - QLineEdit *emailLineEdit; -}; -//! [5] - -class RegisterPage : public QWizardPage -{ - Q_OBJECT - -public: - RegisterPage(QWidget *parent = 0); - - int nextId() const; - -private: - QLabel *nameLabel; - QLabel *upgradeKeyLabel; - QLineEdit *nameLineEdit; - QLineEdit *upgradeKeyLineEdit; -}; - -class DetailsPage : public QWizardPage -{ - Q_OBJECT - -public: - DetailsPage(QWidget *parent = 0); - - int nextId() const; - -private: - QLabel *companyLabel; - QLabel *emailLabel; - QLabel *postalLabel; - QLineEdit *companyLineEdit; - QLineEdit *emailLineEdit; - QLineEdit *postalLineEdit; -}; - -//! [6] -class ConclusionPage : public QWizardPage -{ - Q_OBJECT - -public: - ConclusionPage(QWidget *parent = 0); - - void initializePage(); - int nextId() const; - void setVisible(bool visible); - -private slots: - void printButtonClicked(); - -private: - QLabel *bottomLabel; - QCheckBox *agreeCheckBox; -}; -//! [6] - -#endif diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc deleted file mode 100644 index b06993851..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>images/logo.png</file> - <file>images/watermark.png</file> -</qresource> -</RCC> diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp deleted file mode 100644 index d4dde36bc..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] - i = QInputDialog().getInteger(self, self.tr("QInputDialog().getInteger()"), - self.tr("Percentage:"), 25, 0, 100, 1, ok) - if ok: - self.integerLabel.setText(self.tr("%1%").arg(i)) -//! [0] - -//! [1] - d = QInputDialog().getDouble(self, self.tr("QInputDialog().getDouble()"), - self.tr("Amount:"), 37.56, -10000, 10000, 2, ok) - if ok: - doubleLabel.setText(QString("$%1").arg(d)) -//! [1] - -//! [2] - items = [self.tr("Spring"), self.tr("Summer"), self.tr("Fall"), self.tr("Winter")] - - item = QInputDialog().getItem(self, self.tr("QInputDialog().getItem()"), - selftr("Season:"), items, 0, False, ok) - if ok and not item.isEmpty(): - itemLabel.setText(item) -//! [2] - -//! [3] - text = QInputDialog::getText(self, self.tr("QInputDialog().getText()"), - self.tr("User name:"), QLineEdit.Normal, - QDir().home().dirName(), ok) - if ok and text: - textLabel.setText(text) -//! [3] diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/tabdialog/tabdialog.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/tabdialog/tabdialog.cpp deleted file mode 100644 index 4fff4d631..000000000 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/tabdialog/tabdialog.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -class TabDialog (QDialog): - def __init__(self, fileName, parent = None): - QDialog.__init__(self, parent) - fileInfo = QFileInfo(fileName) - - self.tabWidget = QTabWidget() - self.tabWidget.addTab(GeneralTab(fileInfo), "General") - self.tabWidget.addTab(PermissionsTab(fileInfo), "Permissions") - self.tabWidget.addTab(ApplicationsTab(fileInfo), "Applications") -//! [0] - -//! [1] //! [2] - self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok -//! [1] //! [3] - | QDialogButtonBox.Cancel) - - self.buttonBox.accepted.connect(self.accept) - self.buttonBox.rejected.connect(self.reject) -//! [2] //! [3] - -//! [4] - mainLayout = QVBoxLayout() - mainLayout.addWidget(tabWidget) - mainLayout.addWidget(buttonBox) - self.setLayout(mainLayout) -//! [4] - -//! [5] - self.setWindowTitle("Tab Dialog") -//! [5] - -//! [6] -class GeneralTab (QWidget): - def __init__(self, fileInfo, parent = None): - QWidget.__init__(self, parent) - fileNameLabel = QLabel("File Name:") - fileNameEdit = QLineEdit(fileInfo.fileName()) - - pathLabel = QLabel("Path:") - pathValueLabel = QLabel(fileInfo.absoluteFilePath()) - pathValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken) - - sizeLabel = QLabel("Size:") - size = fileInfo.size()/1024 - sizeValueLabel = QLabel("%d K" % size) - sizeValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken) - - lastReadLabel = QLabel("Last Read:") - lastReadValueLabel = QLabel(fileInfo.lastRead().toString()) - lastReadValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken) - - lastModLabel = QLabel("Last Modified:") - lastModValueLabel = QLabel(fileInfo.lastModified().toString()) - lastModValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken) - - mainLayout = QVBoxLayout() - mainLayout.addWidget(fileNameLabel) - mainLayout.addWidget(fileNameEdit) - mainLayout.addWidget(pathLabel) - mainLayout.addWidget(pathValueLabel) - mainLayout.addWidget(sizeLabel) - mainLayout.addWidget(sizeValueLabel) - mainLayout.addWidget(lastReadLabel) - mainLayout.addWidget(lastReadValueLabel) - mainLayout.addWidget(lastModLabel) - mainLayout.addWidget(lastModValueLabel) - mainLayout.addStretch(1) - self.setLayout(mainLayout) -//! [6] - -//! [7] -class PermissionsTab (QWidget): - def __init__(self, fileInfo, parent = None): - QWidget.__init__(self, parent) - permissionsGroup = QGroupBox("Permissions") - - readable = QCheckBox("Readable") - if fileInfo.isReadable(): - readable.setChecked(True) - - writable = QCheckBox("Writable") - if fileInfo.isWritable(): - writable.setChecked(True) - - executable = QCheckBox("Executable") - if fileInfo.isExecutable(): - executable.setChecked(True) - - ownerGroup = QGroupBox("Ownership") - - ownerLabel = QLabel("Owner") - ownerValueLabel = QLabel(fileInfo.owner()) - ownerValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken) - - groupLabel = QLabel("Group") - groupValueLabel = QLabel(fileInfo.group()) - groupValueLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken) - - permissionsLayout = QVBoxLayout() - permissionsLayout.addWidget(readable) - permissionsLayout.addWidget(writable) - permissionsLayout.addWidget(executable) - permissionsGroup.setLayout(permissionsLayout) - - ownerLayout = QVBoxLayout() - ownerLayout.addWidget(ownerLabel) - ownerLayout.addWidget(ownerValueLabel) - ownerLayout.addWidget(groupLabel) - ownerLayout.addWidget(groupValueLabel) - ownerGroup.setLayout(ownerLayout) - - mainLayout = QVBoxLayout() - mainLayout.addWidget(permissionsGroup) - mainLayout.addWidget(ownerGroup) - mainLayout.addStretch(1) - self.setLayout(mainLayout) -//! [7] - -//! [8] -class ApplicationsTab (QWidget): - def __init__(self, fileInfo, parent = None): - QWidget.__init__(self, parent) - topLabel = QLabel("Open with:") - - applicationsListBox = QListWidget() - applications = [] - - for i in range(30): - applications.append("Application %d" %s i) - applicationsListBox.insertItems(0, applications) - - if fileInfo.suffix().isEmpty(): - alwaysCheckBox = QCheckBox("Always use this application to open this type of file") - else: - alwaysCheckBox = QCheckBox("Always use this application to open files with the extension '%s'" % fileInfo.suffix()) - - layout = QVBoxLayout() - layout.addWidget(topLabel) - layout.addWidget(applicationsListBox) - layout.addWidget(alwaysCheckBox) - self.setLayout(layout) -//! [8] diff --git a/sources/pyside2/doc/codesnippets/examples/graphicsview/simpleanchorlayout/main.cpp b/sources/pyside2/doc/codesnippets/examples/graphicsview/simpleanchorlayout/main.cpp deleted file mode 100644 index 818d865e3..000000000 --- a/sources/pyside2/doc/codesnippets/examples/graphicsview/simpleanchorlayout/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [adding a corner anchor in two steps] -layout.addAnchor(a, Qt.AnchorTop, layout, Qt.AnchorTop) -layout.addAnchor(a, Qt.AnchorLeft, layout, Qt.AnchorLeft) -//! [adding a corner anchor in two steps] - -//! [adding a corner anchor] -layout.addCornerAnchors(a, Qt.TopLeftCorner, layout, Qt.TopLeftCorner) -//! [adding a corner anchor] - -//! [adding anchors] -layout.addAnchor(b, Qt.AnchorLeft, a, Qt.AnchorRight) -layout.addAnchor(b, Qt.AnchorTop, a, Qt.AnchorBottom) -//! [adding anchors] - -//! [adding anchors to match sizes in two steps] -layout.addAnchor(b, Qt.AnchorLeft, c, Qt.AnchorLeft) -layout.addAnchor(b, Qt.AnchorRight, c, Qt.AnchorRight) -//! [adding anchors to match sizes in two steps] - -//! [adding anchors to match sizes] -layout.addAnchors(b, c, Qt.Horizontal) -//! [adding anchors to match sizes] diff --git a/sources/pyside2/doc/codesnippets/examples/imageprovider/imageprovider-example.qml b/sources/pyside2/doc/codesnippets/examples/imageprovider/imageprovider-example.qml deleted file mode 100644 index 58f2599dc..000000000 --- a/sources/pyside2/doc/codesnippets/examples/imageprovider/imageprovider-example.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "ImageProviderCore" // import the plugin that registers the color image provider - -//![0] -Column { - Image { source: "image://colors/yellow" } - Image { source: "image://colors/red" } -} -//![0] diff --git a/sources/pyside2/doc/codesnippets/examples/imageprovider/imageprovider.cpp b/sources/pyside2/doc/codesnippets/examples/imageprovider/imageprovider.cpp deleted file mode 100644 index b3890114b..000000000 --- a/sources/pyside2/doc/codesnippets/examples/imageprovider/imageprovider.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -class ColorImageProvider (QQuickImageProvider): - def __init__(self): - QQuickImageProvider.__init__(self, QQuickImageProvider.Pixmap) - - def requestPixmap(id, size, requestedSize): - width = 100 - height = 50 - - if size: - size.setWidth(width) - size.setHeight(height) - - if requestedSize.width() > 0: - width = requestedSize.width() - if requestedSize.height() > 0: - height = requestedSize.height() - - pixmap = QPixmap(width, height) - pixmap.fill(QColor(id).rgba()) -//![0] - # write the color name - painter = QPainter(pixmap) - f = painter.font() - f.setPixelSize(20) - painter.setFont(f) - painter.setPen(Qt.black) - if requestedSize.isValid(): - painter.scale(requestedSize.width() / width, requestedSize.height() / height) - painter.drawText(QRectF(0, 0, width, height), Qt.AlignCenter, id) -//![1] - return pixmap -//![1] diff --git a/sources/pyside2/doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/sources/pyside2/doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp deleted file mode 100644 index f99b7e18e..000000000 --- a/sources/pyside2/doc/codesnippets/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp +++ /dev/null @@ -1,109 +0,0 @@ -############################################################################ -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the examples of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################ - -//! [0] -def __init__(self, parent): - QSortFilterProxyModel.__init__(self, parent) -//! [0] - -//! [1] -def setFilterMinimumDate(self, date): - self.minDate = date - self.invalidateFilter() - -//! [1] - -//! [2] -def setFilterMaximumDate(self, date): - self.maxDate = date - self.invalidateFilter() - -//! [2] - -//! [3] -def filterAcceptsRow(self, sourceRow, sourceParent): - index0 = sourceModel().index(sourceRow, 0, sourceParent) - index1 = sourceModel().index(sourceRow, 1, sourceParent) - index2 = sourceModel().index(sourceRow, 2, sourceParent) - - regex = filterRegExp() - return (regex.indexIn(sourceModel().data(index0)) != -1 - or regex.indexIn(sourceModel().data(index1)) != -1 - and dateInRange(sourceModel().data(index2)) -//! [3] - -//! [4] //! [5] -def lessThan(self, left, right): - leftData = sourceModel().data(left) - rightData = sourceModel().data(right) -//! [4] - -//! [6] - if isinstance(leftData, QDateTime): - return leftData < rightData - else: - emailPattern = QRegExp("([\\w\\.]*@[\\w\\.]*)") - - if left.column() == 1 && emailPattern.indexIn(leftData) != -1: - leftData = emailPattern.cap(1) - - if right.column() == 1 && emailPattern.indexIn(rightData) != -1: - rightData = emailPattern.cap(1) - - return leftString < rightString - -//! [5] //! [6] - -//! [7] -def dateInRange(self, date): - return (!minDate.isValid() || date > minDate) - && (!maxDate.isValid() || date < maxDate) - -//! [7] diff --git a/sources/pyside2/doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp b/sources/pyside2/doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp deleted file mode 100644 index 7c207d19c..000000000 --- a/sources/pyside2/doc/codesnippets/examples/itemviews/pixelator/pixeldelegate.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -def __init__(self, parent): - QAbstractItemDelegate.__init__(self, parent) - self.pixelSize = 12 -//! [0] - -//! [1] -def paint(self, painter, option, index): -//! [2] - if option.state and QStyle.State_Selected: - painter.fillRect(option.rect, option.palette.highlight()) -//! [1] - -//! [3] - size = qMin(option.rect.width(), option.rect.height()) -//! [3] //! [4] - brightness = index.model().data(index, Qt.DisplayRole).toInt() - radius = (size/2.0) - (brightness/255.0 * size/2.0) - if radius == 0.0: - return -//! [4] - -//! [5] - painter.save() -//! [5] //! [6] - painter.setRenderHint(QPainter.Antialiasing, true) -//! [6] //! [7] - painter.setPen(Qt.NoPen) -//! [7] //! [8] - if option.state and QStyle.State_Selected: -//! [8] //! [9] - painter.setBrush(option.palette.highlightedText()) - else -//! [2] - painter.setBrush(QBrush(Qt.black)) -//! [9] - -//! [10] - painter.drawEllipse(QRectF(option.rect.x() + option.rect.width()/2 - radius, - option.rect.y() + option.rect.height()/2 - radius, - 2*radius, 2*radius)) - painter.restore() -//! [10] - -//! [11] -def sizeHint(self, option, index): - return QSize(self.pixelSize, self.pixelSize) -//! [11] - -//! [12] -def setPixelSize(self, size): - self.pixelSize = size -//! [12] diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.cpp deleted file mode 100644 index b0331aa79..000000000 --- a/sources/pyside2/doc/codesnippets/examples/mainwindows/application/mainwindow.cpp +++ /dev/null @@ -1,359 +0,0 @@ -############################################################################ -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the examples of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################ - -//! [0] -from PySide2.QtGui import * -//! [0] - -//! [1] -def __init__(self): - QMainWindow.__init__(self) -//! [1] //! [2] - textEdit = QPlainTextEdit() - setCentralWidget(textEdit) - - createActions() - createMenus() - createToolBars() - createStatusBar() - - readSettings() - - connect(textEdit.document(), SIGNAL("contentsChanged()"), - self, SLOT("documentWasModified()")) - - setCurrentFile("") - setUnifiedTitleAndToolBarOnMac(True) - -//! [2] - -//! [3] -def closeEvent(self, event): -//! [3] //! [4] - if maybeSave(): - writeSettings() - event.accept() - else: - event.ignore() -//! [4] - -//! [5] -def File(self): -//! [5] //! [6] - if maybeSave(): - textEdit.clear() - setCurrentFile("") -//! [6] - -//! [7] -def open(self): -//! [7] //! [8] - if maybeSave(): - fileName = QFileDialog.getOpenFileName(self) - if !fileName.isEmpty(): - loadFile(fileName) -//! [8] - -//! [9] -def save(self): -//! [9] //! [10] - if curFile.isEmpty(): - return saveAs() - else: - return saveFile(curFile) -//! [10] - -//! [11] -def saveAs(self): -//! [11] //! [12] - fileName = QFileDialog.getSaveFileName(self) - if fileName.isEmpty(): - return False - - return saveFile(fileName) -//! [12] - -//! [13] -def about(self): -//! [13] //! [14] - QMessageBox.about(self, tr("About Application"), - tr("The <b>Application</b> example demonstrates how to " - "write modern GUI applications using Qt, with a menu bar, " - "toolbars, and a status bar.")) - -//! [14] - -//! [15] -def documentWasModified(self): -//! [15] //! [16] - setWindowModified(textEdit.document().isModified()) -//! [16] - -//! [17] -def MainWindow.createActions(self): -//! [17] //! [18] - Act = QAction(QIcon(":/images/new.png"), tr("&New"), self) - Act.setShortcuts(QKeySequence.New) - Act.setStatusTip(tr("Create a new file")) - connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()")) - -//! [19] - openAct = QAction(QIcon(":/images/open.png"), tr("&Open..."), self) - openAct.setShortcuts(QKeySequence.Open) - openAct.setStatusTip(tr("Open an existing file")) - connect(openAct, SIGNAL("triggered()"), self, SLOT("open()")) -//! [18] //! [19] - - saveAct = QAction(QIcon(":/images/save.png"), tr("&Save"), self) - saveAct.setShortcuts(QKeySequence.Save) - saveAct.setStatusTip(tr("Save the document to disk")) - connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()")) - - saveAsAct = QAction(tr("Save &As..."), self) - saveAsAct.setShortcuts(QKeySequence.SaveAs) - saveAsAct.setStatusTip(tr("Save the document under a name")) - connect(saveAsAct, SIGNAL("triggered()"), self, SLOT("saveAs()")) - -//! [20] - exitAct = QAction(tr("E&xit"), self) - exitAct.setShortcut(tr("Ctrl+Q")) -//! [20] - exitAct.setStatusTip(tr("Exit the application")) - connect(exitAct, SIGNAL("triggered()"), self, SLOT("close()")) - -//! [21] - cutAct = QAction(QIcon(":/images/cut.png"), tr("Cu&t"), self) -//! [21] - cutAct.setShortcuts(QKeySequence.Cut) - cutAct.setStatusTip(tr("Cut the current selection's contents to the " - "clipboard")) - connect(cutAct, SIGNAL("triggered()"), textEdit, SLOT("cut()")) - - copyAct = QAction(QIcon(":/images/copy.png"), tr("&Copy"), self) - copyAct.setShortcuts(QKeySequence.Copy) - copyAct.setStatusTip(tr("Copy the current selection's contents to the " - "clipboard")) - connect(copyAct, SIGNAL("triggered()"), textEdit, SLOT("copy()")) - - pasteAct = QAction(QIcon(":/images/paste.png"), tr("&Paste"), self) - pasteAct.setShortcuts(QKeySequence.Paste) - pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current " - "selection")) - connect(pasteAct, SIGNAL("triggered()"), textEdit, SLOT("paste()")) - - aboutAct = QAction(tr("&About"), self) - aboutAct.setStatusTip(tr("Show the application's About box")) - connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()")) - -//! [22] - aboutQtAct = QAction(tr("About &Qt"), self) - aboutQtAct.setStatusTip(tr("Show the Qt library's About box")) - connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()")) -//! [22] - -//! [23] - cutAct.setEnabled(False) -//! [23] //! [24] - copyAct.setEnabled(False) - connect(textEdit, SIGNAL("copyAvailable(bool)"), - cutAct, SLOT("setEnabled(bool)")) - connect(textEdit, SIGNAL("copyAvailable(bool)"), - copyAct, SLOT("setEnabled(bool)")) -} -//! [24] - -//! [25] //! [26] -def createMenus(self): -//! [25] //! [27] - fileMenu = menuBar().addMenu(tr("&File")) - fileMenu.addAction(Act) -//! [28] - fileMenu.addAction(openAct) -//! [28] - fileMenu.addAction(saveAct) -//! [26] - fileMenu.addAction(saveAsAct) - fileMenu.addSeparator() - fileMenu.addAction(exitAct) - - editMenu = menuBar().addMenu(tr("&Edit")) - editMenu.addAction(cutAct) - editMenu.addAction(copyAct) - editMenu.addAction(pasteAct) - - menuBar().addSeparator() - - helpMenu = menuBar().addMenu(tr("&Help")) - helpMenu.addAction(aboutAct) - helpMenu.addAction(aboutQtAct) - -//! [27] - -//! [29] //! [30] -def createToolBars(self): - fileToolBar = addToolBar(tr("File")) - fileToolBar.addAction(Act) -//! [29] //! [31] - fileToolBar.addAction(openAct) -//! [31] - fileToolBar.addAction(saveAct) - - editToolBar = addToolBar(tr("Edit")) - editToolBar.addAction(cutAct) - editToolBar.addAction(copyAct) - editToolBar.addAction(pasteAct) -//! [30] - -//! [32] -def createStatusBar(self): -//! [32] //! [33] - statusBar().showMessage(tr("Ready")) - -//! [33] - -//! [34] //! [35] -def readSettings(self): -//! [34] //! [36] - settings("Trolltech", "Application Example") - pos = settings.value("pos", QPoint(200, 200)).toPoint() - size = settings.value("size", QSize(400, 400)).toSize() - resize(size) - move(pos) - -//! [35] //! [36] - -//! [37] //! [38] -def writeSettings(self): -//! [37] //! [39] - settings = QSettings("Trolltech", "Application Example") - settings.setValue("pos", pos()) - settings.setValue("size", size()) - -//! [38] //! [39] - -//! [40] -def maybeSave(self): -//! [40] //! [41] - if textEdit.document()->isModified(): - ret = QMessageBox.warning(self, tr("Application"), - tr("The document has been modified.\n" - "Do you want to save your changes?"), - QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) - if ret == QMessageBox.Save: - return save() - elif ret == QMessageBox.Cancel: - return False - return True -//! [41] - -//! [42] -def loadFile(self, fileName): -//! [42] //! [43] - file = QFile(fileName) - if !file.open(QFile.ReadOnly | QFile.Text): - QMessageBox.warning(self, tr("Application"), - tr("Cannot read file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())) - return - - in = QTextStream(file) - QApplication.setOverrideCursor(Qt::WaitCursor) - textEdit.setPlainText(in.readAll()) - QApplication.restoreOverrideCursor() - - setCurrentFile(fileName) - statusBar().showMessage(tr("File loaded"), 2000) - -//! [43] - -//! [44] -def saveFile(self, fileName): -//! [44] //! [45] - file = QFile(fileName) - if !file.open(QFile.WriteOnly | QFile::Text): - QMessageBox.warning(self, tr("Application"), - tr("Cannot write file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())) - return False - - out = QTextStream(file) - QApplication.setOverrideCursor(Qt.WaitCursor) - out << textEdit.toPlainText() - QApplication.restoreOverrideCursor() - - setCurrentFile(fileName) - statusBar().showMessage(tr("File saved"), 2000) - return True - -//! [45] - -//! [46] -def setCurrentFile(fileName): -//! [46] //! [47] - curFile = fileName - textEdit.document().setModified(False) - setWindowModified(False) - - if curFile.isEmpty(): - shownName = "untitled.txt" - else: - shownName = strippedName(curFile) - - setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("Application"))) - -//! [47] - -//! [48] -def strippedName(self, fullFileName): -//! [48] //! [49] - return QFileInfo(fullFileName).fileName() -//! [49] diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp deleted file mode 100644 index e1a9f556e..000000000 --- a/sources/pyside2/doc/codesnippets/examples/mainwindows/dockwidgets/mainwindow.cpp +++ /dev/null @@ -1,255 +0,0 @@ -############################################################################ -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the examples of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################ - -//! [0] -from PySide2.QtGui import * -//! [0] - -//! [1] -def __init__(self): - textEdit = QTextEdit() - setCentralWidget(textEdit) - - createActions() - createMenus() - createToolBars() - createStatusBar() - createDockWindows() - - setWindowTitle(tr("Dock Widgets")) - - Letter() - setUnifiedTitleAndToolBarOnMac(True) -//! [1] - -//! [2] -def Letter(self) - textEdit.clear() - - cursor = QTextCursor(textEdit.textCursor()) - cursor.movePosition(QTextCursor.Start) - topFrame = cursor.currentFrame() - topFrameFormat = topFrame.frameFormat() - topFrameFormat.setPadding(16) - topFrame.setFrameFormat(topFrameFormat) - - textFormat = QTextCharFormat() - boldFormat = QTextCharFormat() - boldFormat.setFontWeight(QFont.Bold) - italicFormat = QTextCharFormat() - italicFormat.setFontItalic(True) - - tableFormat = QTextTableFormat() - tableFormat.setBorder(1) - tableFormat.setCellPadding(16) - tableFormat.setAlignment(Qt.AlignRight) - cursor.insertTable(1, 1, tableFormat) - cursor.insertText("The Firm", boldFormat) - cursor.insertBlock() - cursor.insertText("321 City Street", textFormat) - cursor.insertBlock() - cursor.insertText("Industry Park") - cursor.insertBlock() - cursor.insertText("Some Country") - cursor.setPosition(topFrame.lastPosition()) - cursor.insertText(QDate.currentDate().toString("d MMMM yyyy"), textFormat) - cursor.insertBlock() - cursor.insertBlock() - cursor.insertText("Dear ", textFormat) - cursor.insertText("NAME", italicFormat) - cursor.insertText(",", textFormat) - for i in range(3): - cursor.insertBlock() - cursor.insertText(tr("Yours sincerely,"), textFormat) - for i in range(3): - cursor.insertBlock() - cursor.insertText("The Boss", textFormat) - cursor.insertBlock() - cursor.insertText("ADDRESS", italicFormat) -//! [2] - -//! [3] -def print(self) - document = textEdit.document() - printer = QPrinter() - - dlg = QPrintDialog(&printer, self) - if dlg.exec() != QDialog.Accepted: - return - - document.print(printer) - statusBar().showMessage(tr("Ready"), 2000) -//! [3] - -//! [4] -def save(self): - fileName = QFileDialog.getSaveFileName(self, - tr("Choose a file name"), ".", - tr("HTML (*.html *.htm)")) - if fileName.isEmpty(): - return - file = QFile(fileName) - if !file.open(QFile.WriteOnly | QFile::Text): - QMessageBox.warning(self, tr("Dock Widgets"), - tr("Cannot write file %1:\n%2.") - .arg(fileName) - .arg(file.errorString())) - return - - - out = QTextStream(file) - QApplication.setOverrideCursor(Qt::WaitCursor) - out << textEdit.toHtml() - QApplication.restoreOverrideCursor() - - statusBar().showMessage(tr("Saved '%1'").arg(fileName), 2000) - -//! [4] - -//! [5] -def undo(self): - document = textEdit.document() - document.undo() - -//! [5] - -//! [6] -def insertCustomer(self, customer): - if customer.isEmpty(): - return - - customerList = customer.split(", ") - document = textEdit.document() - cursor = document.find("NAME") - if not cursor.isNull(): - cursor.beginEditBlock() - cursor.insertText(customerList.at(0)) - oldcursor = cursor - cursor = document.find("ADDRESS") - if not cursor.isNull(): - for i in range(customerList.size()): - cursor.insertBlock() - cursor.insertText(customerList.at(i)) - - cursor.endEditBlock() - else: - oldcursor.endEditBlock() -//! [6] - -//! [7] -def addParagraph(self, paragraph): - if (paragraph.isEmpty()) - return - - document = textEdit.document() - cursor = document.find(tr("Yours sincerely,")) - if cursor.isNull(): - return - cursor.beginEditBlock() - cursor.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, 2) - cursor.insertBlock() - cursor.insertText(paragraph) - cursor.insertBlock() - cursor.endEditBlock() - -//! [7] - - -//! [8] -def createStatusBar(self): - statusBar().showMessage(tr("Ready")) - -//! [8] - -//! [9] -def createDockWindows(self): - dock = QDockWidget(tr("Customers"), self) - dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) - customerList = QListWidget(dock) - customerList.addItems(QStringList() - << "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton" - << "Jane Doe, Memorabilia, 23 Watersedge, Beaton" - << "Tammy Shea, Tiblanka, 38 Sea Views, Carlton" - << "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal" - << "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston" - << "Sally Hobart, Tiroli Tea, 67 Long River, Fedula") - dock.setWidget(customerList) - addDockWidget(Qt.RightDockWidgetArea, dock) - viewMenu.addAction(dock.toggleViewAction()) - - dock = QDockWidget(tr("Paragraphs"), self) - paragraphsList = QListWidget(dock) - paragraphsList.addItems(QStringList() - << "Thank you for your payment which we have received today." - << "Your order has been dispatched and should be with you " - "within 28 days." - << "We have dispatched those items that were in stock. The " - "rest of your order will be dispatched once all the " - "remaining items have arrived at our warehouse. No " - "additional shipping charges will be made." - << "You made a small overpayment (less than $5) which we " - "will keep on account for you, or return at your request." - << "You made a small underpayment (less than $1), but we have " - "sent your order anyway. We'll add self underpayment to " - "your next bill." - << "Unfortunately you did not send enough money. Please remit " - "an additional $. Your order will be dispatched as soon as " - "the complete amount has been received." - << "You made an overpayment (more than $5). Do you wish to " - "buy more items, or should we return the excess to you?") - dock.setWidget(paragraphsList) - addDockWidget(Qt.RightDockWidgetArea, dock) - viewMenu.addAction(dock.toggleViewAction()) - - connect(customerList, SIGNAL("currentTextChanged(const QString &)"), - self, SLOT("insertCustomer(const QString &)")) - connect(paragraphsList, SIGNAL("currentTextChanged(const QString &)"), - self, SLOT("addParagraph(const QString &)")) -//! [9] diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/mainwindow.cpp deleted file mode 100644 index 6ed5f5466..000000000 --- a/sources/pyside2/doc/codesnippets/examples/mainwindows/mainwindow.cpp +++ /dev/null @@ -1,367 +0,0 @@ -############################################################################ -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the examples of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################ - -from PySide2.QtGui import * - -//! [0] -def __init__(self): - Q__init__(self) - - widget = QWidget() - setCentralWidget(widget) -//! [0] - -//! [1] - topFiller = QWidget() - topFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - - infoLabel = QLabel(tr("<i>Choose a menu option, or right-click to " - "invoke a context menu</i>")) - infoLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) - infoLabel.setAlignment(Qt.AlignCenter) - - bottomFiller = QWidget() - bottomFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - - layout = QVBoxLayout() - layout.setMargin(5) - layout.addWidget(topFiller) - layout.addWidget(infoLabel) - layout.addWidget(bottomFiller) - widget.setLayout(layout) -//! [1] - -//! [2] - createActions() - createMenus() - - message = tr("A context menu is available by right-clicking") - statusBar().showMessage(message) - - setWindowTitle(tr("Menus")) - setMinimumSize(160, 160) - resize(480, 320) - -//! [2] - -//! [3] -def contextMenuEvent(self, event): - menu = QMenu(self) - menu.addAction(cutAct) - menu.addAction(copyAct) - menu.addAction(pasteAct) - menu.exec_(event.globalPos()") - -//! [3] - -def File(self): - infoLabel.setText(tr("Invoked <b>File|New</b>")) - - -def open(self): - infoLabel.setText(tr("Invoked <b>File|Open</b>")) - - -def save(self): - infoLabel.setText(tr("Invoked <b>File|Save</b>")) - -def print_(self): - infoLabel.setText(tr("Invoked <b>File|Print</b>")) - -def undo(self): - infoLabel.setText(tr("Invoked <b>Edit|Undo</b>")) - -def redo(self): - infoLabel.setText(tr("Invoked <b>Edit|Redo</b>")) - -def cut(self): - - infoLabel.setText(tr("Invoked <b>Edit|Cut</b>")) - - -def copy(self): - - infoLabel.setText(tr("Invoked <b>Edit|Copy</b>")) - - -def paste(self): - - infoLabel.setText(tr("Invoked <b>Edit|Paste</b>")) - - -def bold(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Bold</b>")) - - -def italic(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Italic</b>")) - - -def leftAlign(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Left Align</b>")) - - -def rightAlign(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Right Align</b>")) - - -def justify(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Justify</b>")) - - -def center(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Center</b>")) - - -def setLineSpacing(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Set Line Spacing</b>")) - - -def setParagraphSpacing(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Set Paragraph Spacing</b>")) - - -def about(self): - - infoLabel.setText(tr("Invoked <b>Help|About</b>")) - QMessageBox.about(self, tr("About Menu"), - tr("The <b>Menu</b> example shows how to create " - "menu-bar menus and context menus.")) - - -def aboutQt(self): - - infoLabel.setText(tr("Invoked <b>Help|About Qt</b>")) - - -//! [4] -def createActions(self): - -//! [5] - Act = new QAction(tr("&New"), self) - Act.setShortcuts(QKeySequence.New) - Act.setStatusTip(tr("Create a new file")) - connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()")) -//! [4] - - openAct = QAction(tr("&Open..."), self) - openAct.setShortcuts(QKeySequence.Open) - openAct.setStatusTip(tr("Open an existing file")) - connect(openAct, SIGNAL("triggered()"), self, SLOT("open()")) -//! [5] - - saveAct = QAction(tr("&Save"), self) - saveAct.setShortcuts(QKeySequence.Save) - saveAct.setStatusTip(tr("Save the document to disk")) - connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()")) - - printAct = QAction(tr("&Print..."), self) - printAct.setShortcuts(QKeySequence.Print) - printAct.setStatusTip(tr("Print the document")) - connect(printAct, SIGNAL("triggered()"), self, SLOT("print_()")) - - exitAct = QAction(tr("E&xit"), self) - exitAct.setShortcut(tr("Ctrl+Q")) - exitAct.setStatusTip(tr("Exit the application")) - connect(exitAct, SIGNAL("triggered()"), self, SLOT("close()")) - - undoAct = QAction(tr("&Undo"), self) - undoAct.setShortcuts(QKeySequence.Undo) - undoAct.setStatusTip(tr("Undo the last operation")) - connect(undoAct, SIGNAL("triggered()"), self, SLOT("undo()")) - - redoAct = QAction(tr("&Redo"), self) - redoAct.setShortcuts(QKeySequence.Redo) - redoAct.setStatusTip(tr("Redo the last operation")) - connect(redoAct, SIGNAL("triggered()"), self, SLOT("redo()")) - - cutAct = QAction(tr("Cu&t"), self) - cutAct.setShortcuts(QKeySequence.Cut) - cutAct.setStatusTip(tr("Cut the current selection's contents to the " - "clipboard")) - connect(cutAct, SIGNAL("triggered()"), self, SLOT("cut()")) - - copyAct = QAction(tr("&Copy"), self) - copyAct.setShortcut(tr("Ctrl+C")) - copyAct.setStatusTip(tr("Copy the current selection's contents to the " - "clipboard")) - connect(copyAct, SIGNAL("triggered()"), self, SLOT("copy()")) - - pasteAct = QAction(tr("&Paste"), self) - pasteAct.setShortcuts(QKeySequence.Paste) - pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current " - "selection")) - connect(pasteAct, SIGNAL("triggered()"), self, SLOT("paste()")) - - boldAct = QAction(tr("&Bold"), self) - boldAct.setCheckable(True) - boldAct.setShortcut(tr("Ctrl+B")) - boldAct.setStatusTip(tr("Make the text bold")) - connect(boldAct, SIGNAL("triggered()"), self, SLOT("bold()")) - - QFont boldFont = boldAct.font() - boldFont.setBold(True) - boldAct.setFont(boldFont) - - italicAct = QAction(tr("&Italic"), self) - italicAct.setCheckable(True) - italicAct.setShortcut(tr("Ctrl+I")) - italicAct.setStatusTip(tr("Make the text italic")) - connect(italicAct, SIGNAL("triggered()"), self, SLOT("italic()")) - - QFont italicFont = italicAct.font() - italicFont.setItalic(True) - italicAct.setFont(italicFont) - - setLineSpacingAct = QAction(tr("Set &Line Spacing..."), self) - setLineSpacingAct.setStatusTip(tr("Change the gap between the lines of a " - "paragraph")) - connect(setLineSpacingAct, SIGNAL("triggered()"), self, SLOT("setLineSpacing()")) - - setParagraphSpacingAct = QAction(tr("Set &Paragraph Spacing..."), self) - setLineSpacingAct.setStatusTip(tr("Change the gap between paragraphs")) - connect(setParagraphSpacingAct, SIGNAL("triggered()"), - self, SLOT("setParagraphSpacing()")) - - aboutAct = QAction(tr("&About"), self) - aboutAct.setStatusTip(tr("Show the application's About box")) - connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()")) - - aboutQtAct = QAction(tr("About &Qt"), self) - aboutQtAct.setStatusTip(tr("Show the Qt library's About box")) - connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()")) - connect(aboutQtAct, SIGNAL("triggered()"), self, SLOT("aboutQt()")) - - leftAlignAct = QAction(tr("&Left Align"), self) - leftAlignAct.setCheckable(True) - leftAlignAct.setShortcut(tr("Ctrl+L")) - leftAlignAct.setStatusTip(tr("Left align the selected text")) - connect(leftAlignAct, SIGNAL("triggered()"), self, SLOT("leftAlign()")) - - rightAlignAct = QAction(tr("&Right Align"), self) - rightAlignAct.setCheckable(True) - rightAlignAct.setShortcut(tr("Ctrl+R")) - rightAlignAct.setStatusTip(tr("Right align the selected text")) - connect(rightAlignAct, SIGNAL("triggered()"), self, SLOT("rightAlign()")) - - justifyAct = QAction(tr("&Justify"), self) - justifyAct.setCheckable(True) - justifyAct.setShortcut(tr("Ctrl+J")) - justifyAct.setStatusTip(tr("Justify the selected text")) - connect(justifyAct, SIGNAL("triggered()"), self, SLOT("justify()")) - - centerAct = QAction(tr("&Center"), self) - centerAct.setCheckable(True) - centerAct.setShortcut(tr("Ctrl+E")) - centerAct.setStatusTip(tr("Center the selected text")) - connect(centerAct, SIGNAL("triggered()"), self, SLOT("center()")) - -//! [6] //! [7] - alignmentGroup = QActionGroup(self) - alignmentGroup.addAction(leftAlignAct) - alignmentGroup.addAction(rightAlignAct) - alignmentGroup.addAction(justifyAct) - alignmentGroup.addAction(centerAct) - leftAlignAct.setChecked(True) -//! [6] - -//! [7] - -//! [8] -def createMenus(self): - -//! [9] //! [10] - fileMenu = menuBar().addMenu(tr("&File")) - fileMenu.addAction(Act) -//! [9] - fileMenu.addAction(openAct) -//! [10] - fileMenu.addAction(saveAct) - fileMenu.addAction(printAct) -//! [11] - fileMenu.addSeparator() -//! [11] - fileMenu.addAction(exitAct) - - editMenu = menuBar().addMenu(tr("&Edit")) - editMenu.addAction(undoAct) - editMenu.addAction(redoAct) - editMenu.addSeparator() - editMenu.addAction(cutAct) - editMenu.addAction(copyAct) - editMenu.addAction(pasteAct) - editMenu.addSeparator() - - helpMenu = menuBar().addMenu(tr("&Help")) - helpMenu.addAction(aboutAct) - helpMenu.addAction(aboutQtAct) -//! [8] - -//! [12] - formatMenu = editMenu.addMenu(tr("&Format")) - formatMenu.addAction(boldAct) - formatMenu.addAction(italicAct) - formatMenu.addSeparator()->setText(tr("Alignment")) - formatMenu.addAction(leftAlignAct) - formatMenu.addAction(rightAlignAct) - formatMenu.addAction(justifyAct) - formatMenu.addAction(centerAct) - formatMenu.addSeparator() - formatMenu.addAction(setLineSpacingAct) - formatMenu.addAction(setParagraphSpacingAct) -//! [12] diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp deleted file mode 100644 index cfee5cdca..000000000 --- a/sources/pyside2/doc/codesnippets/examples/mainwindows/mdi/mainwindow.cpp +++ /dev/null @@ -1,381 +0,0 @@ -############################################################################ -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the examples of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################ - -from PySide2.QtGui import * - -def __init__(self): - - mdiArea = QMdiArea() - mdiArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) - mdiArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) - setCentralWidget(mdiArea) - connect(mdiArea, SIGNAL("subWindowActivated(QMdiSubWindow *)"), - self, SLOT("updateMenus()")) - windowMapper = QSignalMapper(self) - connect(windowMapper, SIGNAL("mapped(QWidget *)"), - self, SLOT("setActiveSubWindow(QWidget *)")) - - createActions() - createMenus() - createToolBars() - createStatusBar() - updateMenus() - - readSettings() - - setWindowTitle(tr("MDI")) - setUnifiedTitleAndToolBarOnMac(True) - - -def closeEvent(self, event): - mdiArea.closeAllSubWindows() - if self.activeMdiChild(): - event.ignore() - else: - self.writeSettings() - event.accept() - -def File(self): - child = self.createMdiChild() - child.File() - child.show() - - -def open(self): - fileName = QFileDialog.getOpenFileName(self) - if !fileName.isEmpty()): - existing = self.findMdiChild(fileName) - if existing: - mdiArea.setActiveSubWindow(existing) - return - - child = createMdiChild() - if child.loadFile(fileName)): - statusBar().showMessage(tr("File loaded"), 2000) - child.show() - else: - child.close() - -def save(self): - if self.activeMdiChild() && self.activeMdiChild().save(): - self.statusBar().showMessage(tr("File saved"), 2000) - -def saveAs(self): - if self.activeMdiChild() && self.activeMdiChild().saveAs(): - self.statusBar().showMessage(tr("File saved"), 2000) - -def cut(self): - if self.activeMdiChild(): - self.activeMdiChild().cut() - -def copy(self): - if self.activeMdiChild(): - activeMdiChild().copy() - -def paste(self): - if self.activeMdiChild(): - activeMdiChild().paste() - -def about(self): - QMessageBox.about(self, tr("About MDI"), - tr("The <b>MDI</b> example demonstrates how to write multiple " - "document interface applications using Qt.")") - -def updateMenus(self): - hasMdiChild = (activeMdiChild() != 0) - self.saveAct.setEnabled(hasMdiChild) - self.saveAsAct.setEnabled(hasMdiChild) - self.pasteAct.setEnabled(hasMdiChild) - self.closeAct.setEnabled(hasMdiChild) - self.closeAllAct.setEnabled(hasMdiChild) - self.tileAct.setEnabled(hasMdiChild) - self.cascadeAct.setEnabled(hasMdiChild) - self.nextAct.setEnabled(hasMdiChild) - self.previousAct.setEnabled(hasMdiChild) - self.separatorAct.setVisible(hasMdiChild) - - hasSelection = (self.activeMdiChild() && - self.activeMdiChild().textCursor().hasSelection()") - self.cutAct.setEnabled(hasSelection) - self.copyAct.setEnabled(hasSelection) - -def updateWindowMenu(self): - self.windowMenu.clear() - self.windowMenu.addAction(closeAct) - self.windowMenu.addAction(closeAllAct) - self.windowMenu.addSeparator() - self.windowMenu.addAction(tileAct) - self.windowMenu.addAction(cascadeAct) - self.windowMenu.addSeparator() - self.windowMenu.addAction(nextAct) - self.windowMenu.addAction(previousAct) - self.windowMenu.addAction(separatorAct) - - windows = mdiArea.subWindowList() - separatorAct.setVisible(!windows.isEmpty()") - - for i in range((int i = 0 i < windows.size(); ++i) - MdiChild *child = qobject_cast<MdiChild *>(windows.at(i).widget()") - - QString text - if (i < 9) - text = tr("&%1 %2").arg(i + 1) - .arg(child.userFriendlyCurrentFile()") - else - text = tr("%1 %2").arg(i + 1) - .arg(child.userFriendlyCurrentFile()") - - QAction *action = windowMenu.addAction(text) - action.setCheckable(True) - action .setChecked(child == activeMdiChild()") - connect(action, SIGNAL("triggered()"), windowMapper, SLOT("map()")) - windowMapper.setMapping(action, windows.at(i)") - - - -MdiChild *createMdiChild() - - MdiChild *child = MdiChild - mdiArea.addSubWindow(child) - - connect(child, SIGNAL("copyAvailable(bool)"), - cutAct, SLOT("setEnabled(bool)")) - connect(child, SIGNAL("copyAvailable(bool)"), - copyAct, SLOT("setEnabled(bool)")) - - return child - - -def createActions() - - Act = new QAction(QIcon(":/images/new.png"), tr("&New"), self) - Act.setShortcuts(QKeySequence.New) - Act.setStatusTip(tr("Create a new file")") - connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()")) - - openAct = QAction(QIcon(":/images/open.png"), tr("&Open..."), self) - openAct.setShortcuts(QKeySequence.Open) - openAct.setStatusTip(tr("Open an existing file")") - connect(openAct, SIGNAL("triggered()"), self, SLOT("open()")) - - saveAct = QAction(QIcon(":/images/save.png"), tr("&Save"), self) - saveAct.setShortcuts(QKeySequence.Save) - saveAct.setStatusTip(tr("Save the document to disk")") - connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()")) - - saveAsAct = QAction(tr("Save &As..."), self) - saveAsAct.setShortcuts(QKeySequence.SaveAs) - saveAsAct.setStatusTip(tr("Save the document under a name")") - connect(saveAsAct, SIGNAL("triggered()"), self, SLOT("saveAs()")) - -//! [0] - exitAct = QAction(tr("E&xit"), self) - exitAct.setShortcut(tr("Ctrl+Q")") - exitAct.setStatusTip(tr("Exit the application")") - connect(exitAct, SIGNAL("triggered()"), qApp, SLOT("closeAllWindows()")) -//! [0] - - cutAct = QAction(QIcon(":/images/cut.png"), tr("Cu&t"), self) - cutAct.setShortcuts(QKeySequence.Cut) - cutAct.setStatusTip(tr("Cut the current selection's contents to the " - "clipboard")") - connect(cutAct, SIGNAL("triggered()"), self, SLOT("cut()")) - - copyAct = QAction(QIcon(":/images/copy.png"), tr("&Copy"), self) - copyAct.setShortcuts(QKeySequence.Copy) - copyAct.setStatusTip(tr("Copy the current selection's contents to the " - "clipboard")") - connect(copyAct, SIGNAL("triggered()"), self, SLOT("copy()")) - - pasteAct = QAction(QIcon(":/images/paste.png"), tr("&Paste"), self) - pasteAct.setShortcuts(QKeySequence.Paste) - pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current " - "selection")") - connect(pasteAct, SIGNAL("triggered()"), self, SLOT("paste()")) - - closeAct = QAction(tr("Cl&ose"), self) - closeAct.setShortcut(tr("Ctrl+F4")") - closeAct.setStatusTip(tr("Close the active window")") - connect(closeAct, SIGNAL("triggered()"), - mdiArea, SLOT("closeActiveSubWindow()")) - - closeAllAct = QAction(tr("Close &All"), self) - closeAllAct.setStatusTip(tr("Close all the windows")") - connect(closeAllAct, SIGNAL("triggered()"), - mdiArea, SLOT("closeAllSubWindows()")) - - tileAct = QAction(tr("&Tile"), self) - tileAct.setStatusTip(tr("Tile the windows")") - connect(tileAct, SIGNAL("triggered()"), mdiArea, SLOT("tileSubWindows()")) - - cascadeAct = QAction(tr("&Cascade"), self) - cascadeAct.setStatusTip(tr("Cascade the windows")") - connect(cascadeAct, SIGNAL("triggered()"), mdiArea, SLOT("cascadeSubWindows()")) - - nextAct = QAction(tr("Ne&xt"), self) - nextAct.setShortcuts(QKeySequence.NextChild) - nextAct.setStatusTip(tr("Move the focus to the next window")") - connect(nextAct, SIGNAL("triggered()"), - mdiArea, SLOT("activateNextSubWindow()")) - - previousAct = QAction(tr("Pre&vious"), self) - previousAct.setShortcuts(QKeySequence.PreviousChild) - previousAct.setStatusTip(tr("Move the focus to the previous " - "window")") - connect(previousAct, SIGNAL("triggered()"), - mdiArea, SLOT("activatePreviousSubWindow()")) - - separatorAct = QAction(self) - separatorAct.setSeparator(True) - - aboutAct = QAction(tr("&About"), self) - aboutAct.setStatusTip(tr("Show the application's About box")") - connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()")) - - aboutQtAct = QAction(tr("About &Qt"), self) - aboutQtAct.setStatusTip(tr("Show the Qt library's About box")") - connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()")) - - -def createMenus() - - fileMenu = menuBar().addMenu(tr("&File")") - fileMenu.addAction(Act) - fileMenu.addAction(openAct) - fileMenu.addAction(saveAct) - fileMenu.addAction(saveAsAct) - fileMenu.addSeparator() - QAction *action = fileMenu.addAction(tr("Switch layout direction")") - connect(action, SIGNAL("triggered()"), self, SLOT("switchLayoutDirection()")) - fileMenu.addAction(exitAct) - - editMenu = menuBar().addMenu(tr("&Edit")") - editMenu.addAction(cutAct) - editMenu.addAction(copyAct) - editMenu.addAction(pasteAct) - - windowMenu = menuBar().addMenu(tr("&Window")") - updateWindowMenu() - connect(windowMenu, SIGNAL("aboutToShow()"), self, SLOT("updateWindowMenu()")) - - menuBar().addSeparator() - - helpMenu = menuBar().addMenu(tr("&Help")") - helpMenu.addAction(aboutAct) - helpMenu.addAction(aboutQtAct) - - -def createToolBars() - - fileToolBar = addToolBar(tr("File")") - fileToolBar.addAction(Act) - fileToolBar.addAction(openAct) - fileToolBar.addAction(saveAct) - - editToolBar = addToolBar(tr("Edit")") - editToolBar.addAction(cutAct) - editToolBar.addAction(copyAct) - editToolBar.addAction(pasteAct) - - -def createStatusBar() - - statusBar().showMessage(tr("Ready")") - - -def readSettings() - - QSettings settings("Trolltech", "MDI Example") - QPoint pos = settings.value("pos", QPoint(200, 200)").toPoint() - QSize size = settings.value("size", QSize(400, 400)").toSize() - move(pos) - resize(size) - - -def writeSettings() - - QSettings settings("Trolltech", "MDI Example") - settings.setValue("pos", pos()") - settings.setValue("size", size()") - - -MdiChild *activeMdiChild() - - if (QMdiSubWindow *activeSubWindow = mdiArea.activeSubWindow()") - return qobject_cast<MdiChild *>(activeSubWindow.widget()") - return 0 - - -QMdiSubWindow *findMdiChild(const QString &fileName) - - QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath() - - foreach (QMdiSubWindow *window, mdiArea.subWindowList()") - MdiChild *mdiChild = qobject_cast<MdiChild *>(window.widget()") - if (mdiChild.currentFile() == canonicalFilePath) - return window - - return 0 - - -def switchLayoutDirection() - - if (layoutDirection() == Qt.LeftToRight) - qApp.setLayoutDirection(Qt.RightToLeft) - else - qApp.setLayoutDirection(Qt.LeftToRight) - - -def setActiveSubWindow(QWidget *window) - - if (!window) - return - mdiArea.setActiveSubWindow(qobject_cast<QMdiSubWindow *>(window)") - diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp deleted file mode 100644 index 6ed5f5466..000000000 --- a/sources/pyside2/doc/codesnippets/examples/mainwindows/menus/mainwindow.cpp +++ /dev/null @@ -1,367 +0,0 @@ -############################################################################ -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the examples of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################ - -from PySide2.QtGui import * - -//! [0] -def __init__(self): - Q__init__(self) - - widget = QWidget() - setCentralWidget(widget) -//! [0] - -//! [1] - topFiller = QWidget() - topFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - - infoLabel = QLabel(tr("<i>Choose a menu option, or right-click to " - "invoke a context menu</i>")) - infoLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) - infoLabel.setAlignment(Qt.AlignCenter) - - bottomFiller = QWidget() - bottomFiller.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - - layout = QVBoxLayout() - layout.setMargin(5) - layout.addWidget(topFiller) - layout.addWidget(infoLabel) - layout.addWidget(bottomFiller) - widget.setLayout(layout) -//! [1] - -//! [2] - createActions() - createMenus() - - message = tr("A context menu is available by right-clicking") - statusBar().showMessage(message) - - setWindowTitle(tr("Menus")) - setMinimumSize(160, 160) - resize(480, 320) - -//! [2] - -//! [3] -def contextMenuEvent(self, event): - menu = QMenu(self) - menu.addAction(cutAct) - menu.addAction(copyAct) - menu.addAction(pasteAct) - menu.exec_(event.globalPos()") - -//! [3] - -def File(self): - infoLabel.setText(tr("Invoked <b>File|New</b>")) - - -def open(self): - infoLabel.setText(tr("Invoked <b>File|Open</b>")) - - -def save(self): - infoLabel.setText(tr("Invoked <b>File|Save</b>")) - -def print_(self): - infoLabel.setText(tr("Invoked <b>File|Print</b>")) - -def undo(self): - infoLabel.setText(tr("Invoked <b>Edit|Undo</b>")) - -def redo(self): - infoLabel.setText(tr("Invoked <b>Edit|Redo</b>")) - -def cut(self): - - infoLabel.setText(tr("Invoked <b>Edit|Cut</b>")) - - -def copy(self): - - infoLabel.setText(tr("Invoked <b>Edit|Copy</b>")) - - -def paste(self): - - infoLabel.setText(tr("Invoked <b>Edit|Paste</b>")) - - -def bold(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Bold</b>")) - - -def italic(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Italic</b>")) - - -def leftAlign(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Left Align</b>")) - - -def rightAlign(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Right Align</b>")) - - -def justify(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Justify</b>")) - - -def center(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Center</b>")) - - -def setLineSpacing(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Set Line Spacing</b>")) - - -def setParagraphSpacing(self): - - infoLabel.setText(tr("Invoked <b>Edit|Format|Set Paragraph Spacing</b>")) - - -def about(self): - - infoLabel.setText(tr("Invoked <b>Help|About</b>")) - QMessageBox.about(self, tr("About Menu"), - tr("The <b>Menu</b> example shows how to create " - "menu-bar menus and context menus.")) - - -def aboutQt(self): - - infoLabel.setText(tr("Invoked <b>Help|About Qt</b>")) - - -//! [4] -def createActions(self): - -//! [5] - Act = new QAction(tr("&New"), self) - Act.setShortcuts(QKeySequence.New) - Act.setStatusTip(tr("Create a new file")) - connect(Act, SIGNAL("triggered()"), self, SLOT("newFile()")) -//! [4] - - openAct = QAction(tr("&Open..."), self) - openAct.setShortcuts(QKeySequence.Open) - openAct.setStatusTip(tr("Open an existing file")) - connect(openAct, SIGNAL("triggered()"), self, SLOT("open()")) -//! [5] - - saveAct = QAction(tr("&Save"), self) - saveAct.setShortcuts(QKeySequence.Save) - saveAct.setStatusTip(tr("Save the document to disk")) - connect(saveAct, SIGNAL("triggered()"), self, SLOT("save()")) - - printAct = QAction(tr("&Print..."), self) - printAct.setShortcuts(QKeySequence.Print) - printAct.setStatusTip(tr("Print the document")) - connect(printAct, SIGNAL("triggered()"), self, SLOT("print_()")) - - exitAct = QAction(tr("E&xit"), self) - exitAct.setShortcut(tr("Ctrl+Q")) - exitAct.setStatusTip(tr("Exit the application")) - connect(exitAct, SIGNAL("triggered()"), self, SLOT("close()")) - - undoAct = QAction(tr("&Undo"), self) - undoAct.setShortcuts(QKeySequence.Undo) - undoAct.setStatusTip(tr("Undo the last operation")) - connect(undoAct, SIGNAL("triggered()"), self, SLOT("undo()")) - - redoAct = QAction(tr("&Redo"), self) - redoAct.setShortcuts(QKeySequence.Redo) - redoAct.setStatusTip(tr("Redo the last operation")) - connect(redoAct, SIGNAL("triggered()"), self, SLOT("redo()")) - - cutAct = QAction(tr("Cu&t"), self) - cutAct.setShortcuts(QKeySequence.Cut) - cutAct.setStatusTip(tr("Cut the current selection's contents to the " - "clipboard")) - connect(cutAct, SIGNAL("triggered()"), self, SLOT("cut()")) - - copyAct = QAction(tr("&Copy"), self) - copyAct.setShortcut(tr("Ctrl+C")) - copyAct.setStatusTip(tr("Copy the current selection's contents to the " - "clipboard")) - connect(copyAct, SIGNAL("triggered()"), self, SLOT("copy()")) - - pasteAct = QAction(tr("&Paste"), self) - pasteAct.setShortcuts(QKeySequence.Paste) - pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current " - "selection")) - connect(pasteAct, SIGNAL("triggered()"), self, SLOT("paste()")) - - boldAct = QAction(tr("&Bold"), self) - boldAct.setCheckable(True) - boldAct.setShortcut(tr("Ctrl+B")) - boldAct.setStatusTip(tr("Make the text bold")) - connect(boldAct, SIGNAL("triggered()"), self, SLOT("bold()")) - - QFont boldFont = boldAct.font() - boldFont.setBold(True) - boldAct.setFont(boldFont) - - italicAct = QAction(tr("&Italic"), self) - italicAct.setCheckable(True) - italicAct.setShortcut(tr("Ctrl+I")) - italicAct.setStatusTip(tr("Make the text italic")) - connect(italicAct, SIGNAL("triggered()"), self, SLOT("italic()")) - - QFont italicFont = italicAct.font() - italicFont.setItalic(True) - italicAct.setFont(italicFont) - - setLineSpacingAct = QAction(tr("Set &Line Spacing..."), self) - setLineSpacingAct.setStatusTip(tr("Change the gap between the lines of a " - "paragraph")) - connect(setLineSpacingAct, SIGNAL("triggered()"), self, SLOT("setLineSpacing()")) - - setParagraphSpacingAct = QAction(tr("Set &Paragraph Spacing..."), self) - setLineSpacingAct.setStatusTip(tr("Change the gap between paragraphs")) - connect(setParagraphSpacingAct, SIGNAL("triggered()"), - self, SLOT("setParagraphSpacing()")) - - aboutAct = QAction(tr("&About"), self) - aboutAct.setStatusTip(tr("Show the application's About box")) - connect(aboutAct, SIGNAL("triggered()"), self, SLOT("about()")) - - aboutQtAct = QAction(tr("About &Qt"), self) - aboutQtAct.setStatusTip(tr("Show the Qt library's About box")) - connect(aboutQtAct, SIGNAL("triggered()"), qApp, SLOT("aboutQt()")) - connect(aboutQtAct, SIGNAL("triggered()"), self, SLOT("aboutQt()")) - - leftAlignAct = QAction(tr("&Left Align"), self) - leftAlignAct.setCheckable(True) - leftAlignAct.setShortcut(tr("Ctrl+L")) - leftAlignAct.setStatusTip(tr("Left align the selected text")) - connect(leftAlignAct, SIGNAL("triggered()"), self, SLOT("leftAlign()")) - - rightAlignAct = QAction(tr("&Right Align"), self) - rightAlignAct.setCheckable(True) - rightAlignAct.setShortcut(tr("Ctrl+R")) - rightAlignAct.setStatusTip(tr("Right align the selected text")) - connect(rightAlignAct, SIGNAL("triggered()"), self, SLOT("rightAlign()")) - - justifyAct = QAction(tr("&Justify"), self) - justifyAct.setCheckable(True) - justifyAct.setShortcut(tr("Ctrl+J")) - justifyAct.setStatusTip(tr("Justify the selected text")) - connect(justifyAct, SIGNAL("triggered()"), self, SLOT("justify()")) - - centerAct = QAction(tr("&Center"), self) - centerAct.setCheckable(True) - centerAct.setShortcut(tr("Ctrl+E")) - centerAct.setStatusTip(tr("Center the selected text")) - connect(centerAct, SIGNAL("triggered()"), self, SLOT("center()")) - -//! [6] //! [7] - alignmentGroup = QActionGroup(self) - alignmentGroup.addAction(leftAlignAct) - alignmentGroup.addAction(rightAlignAct) - alignmentGroup.addAction(justifyAct) - alignmentGroup.addAction(centerAct) - leftAlignAct.setChecked(True) -//! [6] - -//! [7] - -//! [8] -def createMenus(self): - -//! [9] //! [10] - fileMenu = menuBar().addMenu(tr("&File")) - fileMenu.addAction(Act) -//! [9] - fileMenu.addAction(openAct) -//! [10] - fileMenu.addAction(saveAct) - fileMenu.addAction(printAct) -//! [11] - fileMenu.addSeparator() -//! [11] - fileMenu.addAction(exitAct) - - editMenu = menuBar().addMenu(tr("&Edit")) - editMenu.addAction(undoAct) - editMenu.addAction(redoAct) - editMenu.addSeparator() - editMenu.addAction(cutAct) - editMenu.addAction(copyAct) - editMenu.addAction(pasteAct) - editMenu.addSeparator() - - helpMenu = menuBar().addMenu(tr("&Help")) - helpMenu.addAction(aboutAct) - helpMenu.addAction(aboutQtAct) -//! [8] - -//! [12] - formatMenu = editMenu.addMenu(tr("&Format")) - formatMenu.addAction(boldAct) - formatMenu.addAction(italicAct) - formatMenu.addSeparator()->setText(tr("Alignment")) - formatMenu.addAction(leftAlignAct) - formatMenu.addAction(rightAlignAct) - formatMenu.addAction(justifyAct) - formatMenu.addAction(centerAct) - formatMenu.addSeparator() - formatMenu.addAction(setLineSpacingAct) - formatMenu.addAction(setParagraphSpacingAct) -//! [12] diff --git a/sources/pyside2/doc/codesnippets/examples/mainwindows/sdi/mainwindow.cpp b/sources/pyside2/doc/codesnippets/examples/mainwindows/sdi/mainwindow.cpp deleted file mode 100644 index de169b20d..000000000 --- a/sources/pyside2/doc/codesnippets/examples/mainwindows/sdi/mainwindow.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [implicit tr context] -def createMenus(self): - fileMenu = menuBar().addMenu("&File") -//! [implicit tr context] - -//! [0] - fileToolBar = addToolBar("File") - fileToolBar.addAction(newAct) - fileToolBar.addAction(openAct) -//! [0] diff --git a/sources/pyside2/doc/codesnippets/examples/quick/plugins/plugins.qml b/sources/pyside2/doc/codesnippets/examples/quick/plugins/plugins.qml deleted file mode 100644 index f1b5c2354..000000000 --- a/sources/pyside2/doc/codesnippets/examples/quick/plugins/plugins.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -renderer = QSvgRenderer(QLatin1String("SvgCardDeck.svg")) -black = QGraphicsSvgItem() -red = QGraphicsSvgItem() - -black.setSharedRenderer(renderer) -black.setElementId(QLatin1String("black_joker")) - -red.setSharedRenderer(renderer) -red.setElementId(QLatin1String("red_joker")) -//! [0] diff --git a/sources/pyside2/doc/codesnippets/examples/relationaltablemodel/relationaltablemodel.cpp b/sources/pyside2/doc/codesnippets/examples/relationaltablemodel/relationaltablemodel.cpp deleted file mode 100644 index 48803f05e..000000000 --- a/sources/pyside2/doc/codesnippets/examples/relationaltablemodel/relationaltablemodel.cpp +++ /dev/null @@ -1,120 +0,0 @@ -############################################################################ -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the examples of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################ - -from PySide2.QtGui import * -from PySide2.QtSql import * - -def initializeModel(model): -//! [0] - model.setTable("employee") -//! [0] - - model.setEditStrategy(QSqlTableModel.OnManualSubmit) -//! [1] - model.setRelation(2, QSqlRelation("city", "id", "name")) -//! [1] //! [2] - model.setRelation(3, QSqlRelation("country", "id", "name")) -//! [2] - -//! [3] - model.setHeaderData(0, Qt.Horizontal, QObject::tr("ID")) - model.setHeaderData(1, Qt.Horizontal, QObject::tr("Name")) - model.setHeaderData(2, Qt.Horizontal, QObject::tr("City")) - model.setHeaderData(3, Qt.Horizontal, QObject::tr("Country")) -//! [3] - - model.select() - - -def createView(title, model): -//! [4] - view = QTableView() - view.setModel(model) - view.setItemDelegate(QSqlRelationalDelegate(view)) -//! [4] - view.setWindowTitle(title) - return view - - -def createRelationalTables(): - query = QSqlQuery() - query.exec_("create table employee(id int primary key, name varchar(20), city int, country int)") - query.exec_("insert into employee values(1, 'Espen', 5000, 47)") - query.exec_("insert into employee values(2, 'Harald', 80000, 49)") - query.exec_("insert into employee values(3, 'Sam', 100, 1)") - - query.exec_("create table city(id int, name varchar(20))") - query.exec_("insert into city values(100, 'San Jose')") - query.exec_("insert into city values(5000, 'Oslo')") - query.exec_("insert into city values(80000, 'Munich')") - - query.exec_("create table country(id int, name varchar(20))") - query.exec_("insert into country values(1, 'USA')") - query.exec_("insert into country values(47, 'Norway')") - query.exec_("insert into country values(49, 'Germany')") - - -def main(): - - app = QApplication([]) - if !createConnection(): - return 1 - - createRelationalTables() - - model = QSqlRelationalTableModel() - - initializeModel(model) - - view = createView(QObject.tr("Relational Table Model"), model) - view.show() - - return app.exec_() - diff --git a/sources/pyside2/doc/codesnippets/examples/richtext/textobject/svgtextobject.h b/sources/pyside2/doc/codesnippets/examples/richtext/textobject/svgtextobject.h deleted file mode 100644 index d0b9abf40..000000000 --- a/sources/pyside2/doc/codesnippets/examples/richtext/textobject/svgtextobject.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SVGTEXTOBJECT_H -#define SVGTEXTOBJECT_H - -#include <QTextObjectInterface> - -QT_BEGIN_NAMESPACE -class QTextDocument; -class QTextFormat; -class QPainter; -class QRectF; -class QSizeF; -QT_END_NAMESPACE - -//![0] //![1] -class SvgTextObject(QObject, QTextObjectInterface): - def __init__(self,...): - super(SvgTextObject, self).__init__(...) - ... -//![1] - -public: - QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, - const QTextFormat &format); - void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, - int posInDocument, const QTextFormat &format); -}; -//![0] - -#endif diff --git a/sources/pyside2/doc/codesnippets/examples/widgets/groupbox/window.cpp b/sources/pyside2/doc/codesnippets/examples/widgets/groupbox/window.cpp deleted file mode 100644 index a24e3536f..000000000 --- a/sources/pyside2/doc/codesnippets/examples/widgets/groupbox/window.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of Qt for Python. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -def __init__(self, parent = None): - QWidget.__init__(self, parent) - - grid = QGridLayout() - grid.addWidget(createFirstExclusiveGroup(), 0, 0) - grid.addWidget(createSecondExclusiveGroup(), 1, 0) - grid.addWidget(createNonExclusiveGroup(), 0, 1) - grid.addWidget(createPushButtonGroup(), 1, 1) - setLayout(grid) - - setWindowTitle("Group Boxes") - resize(480, 320) - -//! [0] - -//! [1] -def createFirstExclusiveGroup(self): -//! [2] - groupBox = QGroupBox("Exclusive Radio Buttons") - - radio1 = QRadioButton("&Radio button 1") - radio2 = QRadioButton("R&adio button 2") - radio3 = QRadioButton("Ra&dio button 3") - - radio1.setChecked(True) -//! [1] //! [3] - - vbox = QVBoxLayout() - vbox.addWidget(radio1) - vbox.addWidget(radio2) - vbox.addWidget(radio3) - vbox.addStretch(1) - groupBox.setLayout(vbox) -//! [2] - return groupBox -//! [3] - -//! [4] -def createSecondExclusiveGroup(self): - groupBox = QGroupBox("E&xclusive Radio Buttons") - groupBox.setCheckable(True) - groupBox.setChecked(False) -//! [4] - -//! [5] - radio1 = QRadioButton("Rad&io button 1") - radio2 = QRadioButton("Radi&o button 2") - radio3 = QRadioButton("Radio &button 3") - radio1.setChecked(True) - checkBox = QCheckBox("Ind&ependent checkbox") - checkBox.setChecked(True) -//! [5] - -//! [6] - vbox = QVBoxLayout() - vbox.addWidget(radio1) - vbox.addWidget(radio2) - vbox.addWidget(radio3) - vbox.addWidget(checkBox) - vbox.addStretch(1) - groupBox.setLayout(vbox) - - return groupBox -//! [6] - -//! [7] -def createNonExclusiveGroup(self): - groupBox = QGroupBox("Non-Exclusive Checkboxes") - groupBox.setFlat(True) -//! [7] - -//! [8] - checkBox1 = QCheckBox("&Checkbox 1") - checkBox2 = QCheckBox("C&heckbox 2") - checkBox2.setChecked(True) - tristateBox = QCheckBox("Tri-&state button") - tristateBox.setTristate(True) -//! [8] - tristateBox.setCheckState(Qt.PartiallyChecked) - -//! [9] - vbox = QVBoxLayout() - vbox.addWidget(checkBox1) - vbox.addWidget(checkBox2) - vbox.addWidget(tristateBox) - vbox.addStretch(1) - groupBox.setLayout(vbox) - - return groupBox -//! [9] - -//! [10] -def createPushButtonGroup(self): - groupBox = QGroupBox("&Push Buttons") - groupBox.setCheckable(True) - groupBox.setChecked(True) -//! [10] - -//! [11] - pushButton = QPushButton("&Normal Button") - toggleButton = QPushButton("&Toggle Button") - toggleButton.setCheckable(True) - toggleButton.setChecked(True) - flatButton = QPushButton("&Flat Button") - flatButton.setFlat(True) -//! [11] - -//! [12] - popupButton = QPushButton("Pop&up Button") - menu = QMenu(self) - menu.addAction("&First Item") - menu.addAction("&Second Item") - menu.addAction("&Third Item") - menu.addAction("F&ourth Item") - popupButton.setMenu(menu) -//! [12] - - newAction = menu.addAction("Submenu") - QMenu *subMenu = QMenu("Popup Submenu") - subMenu.addAction("Item 1") - subMenu.addAction("Item 2") - subMenu.addAction("Item 3") - newAction.setMenu(subMenu) - -//! [13] - vbox = QVBoxLayout() - vbox.addWidget(pushButton) - vbox.addWidget(toggleButton) - vbox.addWidget(flatButton) - vbox.addWidget(popupButton) - vbox.addStretch(1) - groupBox.setLayout(vbox) - - return groupBox -} -//! [13] diff --git a/sources/pyside2/doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp b/sources/pyside2/doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp deleted file mode 100644 index a289c5cea..000000000 --- a/sources/pyside2/doc/codesnippets/examples/widgets/icons/iconsizespinbox.cpp +++ /dev/null @@ -1,72 +0,0 @@ -############################################################################ -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the examples of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################ - - -//! [0] -def __init__(self, parent): - QSpinBox.__init__(self, parent) - -//! [0] - -//! [1] -def valueFromText(self, text): - regExp = QRegExp(tr("(\\d+)(\\s*[xx]\\s*\\d+)?")) - - if regExp.exactMatch(text): - return regExp.cap(1).toInt() - else: - return 0 -//! [1] - -//! [2] -def textFromValue(self, value): - return self.tr("%1 x %1").arg(value) - -//! [2] diff --git a/sources/pyside2/doc/codesnippets/examples/widgets/spinboxes/window.cpp b/sources/pyside2/doc/codesnippets/examples/widgets/spinboxes/window.cpp deleted file mode 100644 index 7eace108a..000000000 --- a/sources/pyside2/doc/codesnippets/examples/widgets/spinboxes/window.cpp +++ /dev/null @@ -1,249 +0,0 @@ -############################################################################ -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the examples of Qt for Python. -## -## $QT_BEGIN_LICENSE:BSD$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## BSD License Usage -## Alternatively, you may use this file under the terms of the BSD license -## as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################ - -from PySide2.QtGui import * - -//! [0] -def __init__(self): - createSpinBoxes() - createDateTimeEdits() - createDoubleSpinBoxes() - - layout = QHBoxLayout() - layout.addWidget(spinBoxesGroup) - layout.addWidget(editsGroup) - layout.addWidget(doubleSpinBoxesGroup) - setLayout(layout) - - setWindowTitle(tr("Spin Boxes")) -//! [0] - -//! [1] -def createSpinBoxes(self): - spinBoxesGroup = QGroupBox(tr("Spinboxes")) - - integerLabel = QLabel(tr("Enter a value between " - "%1 and %2:").arg(-20).arg(20)) - integerSpinBox = QSpinBox() - integerSpinBox.setRange(-20, 20) - integerSpinBox.setSingleStep(1) - integerSpinBox.setValue(0) -//! [1] - -//! [2] - zoomLabel = QLabel(tr("Enter a zoom value between " - "%1 and %2:").arg(0).arg(1000)) -//! [3] - zoomSpinBox = QSpinBox() - zoomSpinBox.setRange(0, 1000) - zoomSpinBox.setSingleStep(10) - zoomSpinBox.setSuffix("%") - zoomSpinBox.setSpecialValueText(tr("Automatic")) - zoomSpinBox.setValue(100) -//! [2] //! [3] - -//! [4] - priceLabel = QLabel(tr("Enter a price between " - "%1 and %2:").arg(0).arg(999)) - priceSpinBox = QSpinBox() - priceSpinBox.setRange(0, 999) - priceSpinBox.setSingleStep(1) - priceSpinBox.setPrefix("$") - priceSpinBox.setValue(99) -//! [4] //! [5] - - spinBoxLayout = QVBoxLayout() - spinBoxLayout.addWidget(integerLabel) - spinBoxLayout.addWidget(integerSpinBox) - spinBoxLayout.addWidget(zoomLabel) - spinBoxLayout.addWidget(zoomSpinBox) - spinBoxLayout.addWidget(priceLabel) - spinBoxLayout.addWidget(priceSpinBox) - spinBoxesGroup.setLayout(spinBoxLayout) - -//! [5] - -//! [6] -def createDateTimeEdits(self): - editsGroup = QGroupBox(tr("Date and time spin boxes")) - - dateLabel = QLabel() - dateEdit = QDateEdit(QDate.currentDate()) - dateEdit.setDateRange(QDate(2005, 1, 1), QDate(2010, 12, 31)) - dateLabel.setText(tr("Appointment date (between %0 and %1):") - .arg(dateEdit.minimumDate().toString(Qt.ISODate)) - .arg(dateEdit.maximumDate().toString(Qt.ISODate))) -//! [6] - -//! [7] - timeLabel = QLabel() - timeEdit = QTimeEdit(QTime.currentTime()) - timeEdit.setTimeRange(QTime(9, 0, 0, 0), QTime(16, 30, 0, 0)) - timeLabel.setText(tr("Appointment time (between %0 and %1):") - .arg(timeEdit.minimumTime().toString(Qt.ISODate)) - .arg(timeEdit.maximumTime().toString(Qt.ISODate))) -//! [7] - -//! [8] - meetingLabel = QLabel() - meetingEdit = QDateTimeEdit(QDateTime.currentDateTime()) -//! [8] - -//! [9] - formatLabel = QLabel(tr("Format string for the meeting date " - "and time:")) - formatComboBox = QComboBox() - formatComboBox.addItem("yyyy-MM-dd hh:mm:ss (zzz 'ms')") - formatComboBox.addItem("hh:mm:ss MM/dd/yyyy") - formatComboBox.addItem("hh:mm:ss dd/MM/yyyy") - formatComboBox.addItem("hh:mm:ss") - formatComboBox.addItem("hh:mm ap") -//! [9] //! [10] - - connect(formatComboBox, SIGNAL("activated(const QString &)"), - self, SLOT("setFormatString(const QString &)")) -//! [10] - - setFormatString(formatComboBox.currentText()) - -//! [11] - editsLayout = QVBoxLayout() - editsLayout.addWidget(dateLabel) - editsLayout.addWidget(dateEdit) - editsLayout.addWidget(timeLabel) - editsLayout.addWidget(timeEdit) - editsLayout.addWidget(meetingLabel) - editsLayout.addWidget(meetingEdit) - editsLayout.addWidget(formatLabel) - editsLayout.addWidget(formatComboBox) - editsGroup.setLayout(editsLayout) -//! [11] - -//! [12] -def setFormatString(self, formatString): - meetingEdit.setDisplayFormat(formatString) -//! [12] //! [13] - if meetingEdit.displayedSections() & QDateTimeEdit.DateSections_Mask: - meetingEdit.setDateRange(QDate(2004, 11, 1), QDate(2005, 11, 30)) - meetingLabel.setText(tr("Meeting date (between %0 and %1):") - .arg(meetingEdit.minimumDate().toString(Qt.ISODate)) - .arg(meetingEdit.maximumDate().toString(Qt.ISODate))) - else: - meetingEdit.setTimeRange(QTime(0, 7, 20, 0), QTime(21, 0, 0, 0)) - meetingLabel.setText(tr("Meeting time (between %0 and %1):") - .arg(meetingEdit.minimumTime().toString(Qt.ISODate)) - .arg(meetingEdit.maximumTime().toString(Qt.ISODate))) -//! [13] - -//! [14] -def createDoubleSpinBoxes(): - doubleSpinBoxesGroup = QGroupBox(tr("Double precision spinboxes")) - - precisionLabel = QLabel(tr("Number of decimal places " - "to show:")) - precisionSpinBox = QSpinBox() - precisionSpinBox.setRange(0, 100) - precisionSpinBox.setValue(2) -//! [14] - -//! [15] - doubleLabel = QLabel(tr("Enter a value between " - "%1 and %2:").arg(-20).arg(20)) - doubleSpinBox = QDoubleSpinBox () - doubleSpinBox.setRange(-20.0, 20.0) - doubleSpinBox.setSingleStep(1.0) - doubleSpinBox.setValue(0.0) -//! [15] - -//! [16] - scaleLabel = QLabel(tr("Enter a scale factor between " - "%1 and %2:").arg(0).arg(1000.0)) - scaleSpinBox = QDoubleSpinBox() - scaleSpinBox.setRange(0.0, 1000.0) - scaleSpinBox.setSingleStep(10.0) - scaleSpinBox.setSuffix("%") - scaleSpinBox.setSpecialValueText(tr("No scaling")) - scaleSpinBox.setValue(100.0) -//! [16] - -//! [17] - priceLabel = QLabel(tr("Enter a price between " - "%1 and %2:").arg(0).arg(1000)) - priceSpinBox = QDoubleSpinBox() - priceSpinBox.setRange(0.0, 1000.0) - priceSpinBox.setSingleStep(1.0) - priceSpinBox.setPrefix("$") - priceSpinBox.setValue(99.99) - - connect(precisionSpinBox, SIGNAL("valueChanged(int)"), -//! [17] - self, SLOT("changePrecision(int))") - -//! [18] - spinBoxLayout = QVBoxLayout() - spinBoxLayout.addWidget(precisionLabel) - spinBoxLayout.addWidget(precisionSpinBox) - spinBoxLayout.addWidget(doubleLabel) - spinBoxLayout.addWidget(doubleSpinBox) - spinBoxLayout.addWidget(scaleLabel) - spinBoxLayout.addWidget(scaleSpinBox) - spinBoxLayout.addWidget(priceLabel) - spinBoxLayout.addWidget(priceSpinBox) - doubleSpinBoxesGroup.setLayout(spinBoxLayout) -} -//! [18] - -//! [19] -def changePrecision(self, int) - doubleSpinBox.setDecimals(decimals) - scaleSpinBox.setDecimals(decimals) - priceSpinBox.setDecimals(decimals) - -//! [19] diff --git a/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.h b/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.h deleted file mode 100644 index cb7207333..000000000 --- a/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XBELREADER_H -#define XBELREADER_H - -#include <QIcon> -#include <QXmlStreamReader> - -QT_BEGIN_NAMESPACE -class QTreeWidget; -class QTreeWidgetItem; -QT_END_NAMESPACE - -//! [0] -class XbelReader (QXmlStreamReader): -//! [1] - def __init__(self, treeWidget): - ... -//! [1] - - def read(self, device); - ... - -//! [2] - def readUnknownElement(self): - ... - def readXBEL(self): - ... - def readTitle(self, item): - ... - def readSeparator(self, item): - ... - def readFolder(self, item): - ... - def readBookmark(self, item): - ... - def createChildItem(self, item): - ... -//! [2] -//! [0] - -#endif |