aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2016-07-12 16:56:03 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2016-07-13 11:51:17 +0000
commit090a2dbf62ecff31de21b1b1d2ffb11a7117c61a (patch)
tree2c6e7c25b0e55201dd7509d29023e6035ced4cad
parentc8c9f64eb4657c54f063f01f00116732cb3fc100 (diff)
Port examples
Adapt to Qt 5 and fix license. Done-with: Alexandru Croitor <alexandru.croitor@qt.io> Change-Id: I08fece5bbb9350ddb2e6a5cd3f9c603a9f8d44fd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rwxr-xr-xexamples/animation/animatedtiles/animatedtiles.py75
-rwxr-xr-xexamples/animation/appchooser/appchooser.py29
-rwxr-xr-xexamples/animation/easing/easing.py60
-rw-r--r--examples/animation/easing/ui_form.py78
-rwxr-xr-xexamples/animation/states/states.py52
-rwxr-xr-xexamples/dialogs/classwizard/classwizard.py146
-rwxr-xr-xexamples/dialogs/extension.py91
-rwxr-xr-xexamples/dialogs/findfiles.py91
-rwxr-xr-xexamples/dialogs/standarddialogs.py187
-rwxr-xr-xexamples/dialogs/trivialwizard.py75
-rwxr-xr-xexamples/effects/lighting.py56
-rwxr-xr-xexamples/graphicsview/anchorlayout.py60
-rwxr-xr-xexamples/graphicsview/collidingmice/collidingmice.py72
-rwxr-xr-xexamples/graphicsview/diagramscene/diagramscene.py173
-rwxr-xr-xexamples/graphicsview/dragdroprobot/dragdroprobot.py68
-rwxr-xr-xexamples/graphicsview/elasticnodes.py92
-rw-r--r--examples/itemviews/addressbook/adddialogwidget.py91
-rwxr-xr-xexamples/itemviews/addressbook/addressbook.py92
-rw-r--r--examples/itemviews/addressbook/addresswidget.py91
-rw-r--r--examples/itemviews/addressbook/newaddresstab.py89
-rw-r--r--examples/itemviews/addressbook/tablemodel.py87
-rwxr-xr-xexamples/itemviews/basicsortfiltermodel.py86
-rwxr-xr-xexamples/itemviews/fetchmore.py71
-rwxr-xr-xexamples/itemviews/stardelegate/stardelegate.py93
-rw-r--r--examples/itemviews/stardelegate/stareditor.py87
-rw-r--r--examples/itemviews/stardelegate/starrating.py88
-rwxr-xr-xexamples/layouts/basiclayouts.py91
-rwxr-xr-xexamples/layouts/dynamiclayouts.py55
-rwxr-xr-xexamples/layouts/flowlayout.py71
-rw-r--r--examples/mainwindows/README10
-rwxr-xr-xexamples/mainwindows/application/application.py106
-rwxr-xr-xexamples/network/fortuneclient.py83
-rwxr-xr-xexamples/network/fortuneserver.py59
-rwxr-xr-xexamples/richtext/orderform.py99
-rwxr-xr-xexamples/richtext/syntaxhighlighter.py69
-rwxr-xr-xexamples/richtext/syntaxhighlighter/syntaxhighlighter.py63
-rwxr-xr-xexamples/richtext/textobject/textobject.py65
-rwxr-xr-xexamples/script/helloscript.py50
-rwxr-xr-xexamples/state-machine/eventtrans.py46
-rwxr-xr-xexamples/state-machine/factstates.py46
-rwxr-xr-xexamples/state-machine/pingpong.py46
-rwxr-xr-xexamples/state-machine/rogue.py47
-rwxr-xr-xexamples/state-machine/trafficlight.py47
-rwxr-xr-xexamples/state-machine/twowaybutton.py45
-rwxr-xr-xexamples/tools/codecs/codecs.py97
-rwxr-xr-xexamples/tools/regexp.py103
-rwxr-xr-xexamples/tools/settingseditor/settingseditor.py149
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t1.py48
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t10.py78
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t11.py86
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t12.py90
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t13.py109
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t14.py123
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t2.py48
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t3.py50
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t4.py54
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t5.py60
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t6.py68
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t7.py70
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t8.py74
-rw-r--r--[-rwxr-xr-x]examples/tutorial/t9.py74
-rwxr-xr-xexamples/tutorials/addressbook/part1.py54
-rwxr-xr-xexamples/tutorials/addressbook/part2.py68
-rwxr-xr-xexamples/tutorials/addressbook/part3.py74
-rwxr-xr-xexamples/tutorials/addressbook/part4.py92
-rwxr-xr-xexamples/tutorials/addressbook/part5.py110
-rwxr-xr-xexamples/tutorials/addressbook/part6.py124
-rwxr-xr-xexamples/tutorials/addressbook/part7.py132
-rw-r--r--[-rwxr-xr-x]examples/widgets/tetrix.py81
-rwxr-xr-xexamples/xml/dombookmarks/dombookmarks.py99
-rwxr-xr-xexamples/xmlpatterns/schema/schema.py55
-rw-r--r--examples/xmlpatterns/schema/ui_schema.py38
72 files changed, 3984 insertions, 1702 deletions
diff --git a/examples/animation/animatedtiles/animatedtiles.py b/examples/animation/animatedtiles/animatedtiles.py
index e08a25f..d3b649d 100755
--- a/examples/animation/animatedtiles/animatedtiles.py
+++ b/examples/animation/animatedtiles/animatedtiles.py
@@ -1,22 +1,59 @@
#!/usr/bin/env python
-# This file was taken from Riverbank's examples,
-# which was an adaptation of the original C++ Qt's examples.
-
-
-from PySide2 import QtCore, QtGui
+#############################################################################
+##
+## Copyright (C) 2010 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui, QtWidgets
import animatedtiles_rc
-# PyQt doesn't support deriving from more than one wrapped class so we use
+# Deriving from more than one wrapped class is not supported, so we use
# composition and delegate the property.
class Pixmap(QtCore.QObject):
def __init__(self, pix):
super(Pixmap, self).__init__()
- self.pixmap_item = QtGui.QGraphicsPixmapItem(pix)
- self.pixmap_item.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache)
+ self.pixmap_item = QtWidgets.QGraphicsPixmapItem(pix)
+ self.pixmap_item.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
def set_pos(self, pos):
self.pixmap_item.setPos(pos)
@@ -27,7 +64,7 @@ class Pixmap(QtCore.QObject):
pos = QtCore.Property(QtCore.QPointF, get_pos, set_pos)
-class Button(QtGui.QGraphicsWidget):
+class Button(QtWidgets.QGraphicsWidget):
pressed = QtCore.Signal()
def __init__(self, pixmap, parent=None):
@@ -36,7 +73,7 @@ class Button(QtGui.QGraphicsWidget):
self._pix = pixmap
self.setAcceptHoverEvents(True)
- self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache)
+ self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
def boundingRect(self):
return QtCore.QRectF(-65, -65, 130, 130)
@@ -48,11 +85,11 @@ class Button(QtGui.QGraphicsWidget):
return path
def paint(self, painter, option, widget):
- down = option.state & QtGui.QStyle.State_Sunken
+ down = option.state & QtWidgets.QStyle.State_Sunken
r = self.boundingRect()
grad = QtGui.QLinearGradient(r.topLeft(), r.bottomRight())
- if option.state & QtGui.QStyle.State_MouseOver:
+ if option.state & QtWidgets.QStyle.State_MouseOver:
color_0 = QtCore.Qt.white
else:
color_0 = QtCore.Qt.lightGray
@@ -96,7 +133,7 @@ class Button(QtGui.QGraphicsWidget):
self.update()
-class View(QtGui.QGraphicsView):
+class View(QtWidgets.QGraphicsView):
def resizeEvent(self, event):
super(View, self).resizeEvent(event)
self.fitInView(self.sceneRect(), QtCore.Qt.KeepAspectRatio)
@@ -107,12 +144,12 @@ if __name__ == '__main__':
import sys
import math
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
kineticPix = QtGui.QPixmap(':/images/kinetic.png')
bgPix = QtGui.QPixmap(':/images/Time-For-Lunch-2.jpg')
- scene = QtGui.QGraphicsScene(-350, -350, 700, 700)
+ scene = QtWidgets.QGraphicsScene(-350, -350, 700, 700)
items = []
for i in range(64):
@@ -124,7 +161,7 @@ if __name__ == '__main__':
scene.addItem(item.pixmap_item)
# Buttons.
- buttonParent = QtGui.QGraphicsRectItem()
+ buttonParent = QtWidgets.QGraphicsRectItem()
ellipseButton = Button(QtGui.QPixmap(':/images/ellipse.png'), buttonParent)
figure8Button = Button(QtGui.QPixmap(':/images/figure8.png'), buttonParent)
randomButton = Button(QtGui.QPixmap(':/images/random.png'), buttonParent)
@@ -138,7 +175,7 @@ if __name__ == '__main__':
centeredButton.setPos(100, 100)
scene.addItem(buttonParent)
- buttonParent.scale(0.75, 0.75)
+ buttonParent.setTransform(QtGui.QTransform().scale(0.75, 0.75))
buttonParent.setPos(200, 200)
buttonParent.setZValue(65)
@@ -178,9 +215,9 @@ if __name__ == '__main__':
# Ui.
view = View(scene)
view.setWindowTitle("Animated Tiles")
- view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)
+ view.setViewportUpdateMode(QtWidgets.QGraphicsView.BoundingRectViewportUpdate)
view.setBackgroundBrush(QtGui.QBrush(bgPix))
- view.setCacheMode(QtGui.QGraphicsView.CacheBackground)
+ view.setCacheMode(QtWidgets.QGraphicsView.CacheBackground)
view.setRenderHints(
QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform)
view.show()
diff --git a/examples/animation/appchooser/appchooser.py b/examples/animation/appchooser/appchooser.py
index 7d0e360..7501bf4 100755
--- a/examples/animation/appchooser/appchooser.py
+++ b/examples/animation/appchooser/appchooser.py
@@ -3,10 +3,10 @@
#############################################################################
##
## Copyright (C) 2010 Riverbank Computing Limited.
-## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-## All rights reserved.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the examples of PyQt.
+## This file is part of the PySide examples of the Qt Toolkit.
##
## $QT_BEGIN_LICENSE:BSD$
## You may use this file under the terms of the BSD license as follows:
@@ -20,10 +20,10 @@
## notice, this list of conditions and the following disclaimer in
## the documentation and/or other materials provided with the
## distribution.
-## * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-## the names of its contributors may be used to endorse or promote
-## products derived from this software without specific prior written
-## permission.
+## * 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
@@ -36,20 +36,17 @@
## 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$
##
#############################################################################
-# This file was taken from PyQt examples,
-# which are adaptations of the original C++ Qt's examples.
-
-
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
import appchooser_rc
-class Pixmap(QtGui.QGraphicsWidget):
+class Pixmap(QtWidgets.QGraphicsWidget):
clicked = QtCore.Signal()
def __init__(self, pix, parent=None):
@@ -90,7 +87,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
p1 = Pixmap(QtGui.QPixmap(':/digikam.png'))
p2 = Pixmap(QtGui.QPixmap(':/akregator.png'))
@@ -102,14 +99,14 @@ if __name__ == '__main__':
p3.setGeometry(QtCore.QRectF(236.0, 236.0, 64.0, 64.0))
p4.setGeometry(QtCore.QRectF(0.0, 236.0, 64.0, 64.0))
- scene = QtGui.QGraphicsScene(0, 0, 300, 300)
+ scene = QtWidgets.QGraphicsScene(0, 0, 300, 300)
scene.setBackgroundBrush(QtCore.Qt.white)
scene.addItem(p1)
scene.addItem(p2)
scene.addItem(p3)
scene.addItem(p4)
- window = QtGui.QGraphicsView(scene)
+ window = QtWidgets.QGraphicsView(scene)
window.setFrameStyle(0)
window.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
window.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
diff --git a/examples/animation/easing/easing.py b/examples/animation/easing/easing.py
index 8e65094..2887968 100755
--- a/examples/animation/easing/easing.py
+++ b/examples/animation/easing/easing.py
@@ -1,6 +1,47 @@
#!/usr/bin/env python
-from PySide2 import QtCore, QtGui
+#############################################################################
+##
+## Copyright (C) 2010 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui, QtWidgets
import easing_rc
from ui_form import Ui_Form
@@ -43,14 +84,14 @@ class Animation(QtCore.QPropertyAnimation):
else:
super(Animation, self).updateCurrentTime(currentTime)
-# PyQt doesn't support deriving from more than one wrapped class so we use
+# PySide2 doesn't support deriving from more than one wrapped class so we use
# composition and delegate the property.
class Pixmap(QtCore.QObject):
def __init__(self, pix):
super(Pixmap, self).__init__()
- self.pixmap_item = QtGui.QGraphicsPixmapItem(pix)
- self.pixmap_item.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache)
+ self.pixmap_item = QtWidgets.QGraphicsPixmapItem(pix)
+ self.pixmap_item.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
def set_pos(self, pos):
self.pixmap_item.setPos(pos)
@@ -61,12 +102,12 @@ class Pixmap(QtCore.QObject):
pos = QtCore.Property(QtCore.QPointF, get_pos, set_pos)
-class Window(QtGui.QWidget):
+class Window(QtWidgets.QWidget):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.m_iconSize = QtCore.QSize(64, 64)
- self.m_scene = QtGui.QGraphicsScene()
+ self.m_scene = QtWidgets.QGraphicsScene()
m_ui = Ui_Form()
m_ui.setupUi(self)
@@ -116,7 +157,8 @@ class Window(QtGui.QWidget):
curve_types = [(n, c) for n, c in QtCore.QEasingCurve.__dict__.items()
if isinstance(c, QtCore.QEasingCurve.Type) \
and c != QtCore.QEasingCurve.Custom \
- and c != QtCore.QEasingCurve.NCurveTypes]
+ and c != QtCore.QEasingCurve.NCurveTypes \
+ and c != QtCore.QEasingCurve.TCBSpline]
curve_types.sort(key=lambda ct: ct[1])
painter.begin(pix)
@@ -160,7 +202,7 @@ class Window(QtGui.QWidget):
painter.strokePath(curvePath, QtGui.QColor(32, 32, 32))
painter.setRenderHint(QtGui.QPainter.Antialiasing, False)
- item = QtGui.QListWidgetItem()
+ item = QtWidgets.QListWidgetItem()
item.setIcon(QtGui.QIcon(pix))
item.setText(curve_name)
self.m_ui.easingCurvePicker.addItem(item)
@@ -211,7 +253,7 @@ class Window(QtGui.QWidget):
if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
w = Window()
w.resize(600, 600)
w.show()
diff --git a/examples/animation/easing/ui_form.py b/examples/animation/easing/ui_form.py
index 93d6361..4ecf485 100644
--- a/examples/animation/easing/ui_form.py
+++ b/examples/animation/easing/ui_form.py
@@ -7,92 +7,92 @@
#
# WARNING! All changes made in this file will be lost!
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(545, 471)
- self.gridLayout = QtGui.QGridLayout(Form)
+ self.gridLayout = QtWidgets.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
- self.easingCurvePicker = QtGui.QListWidget(Form)
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
+ self.easingCurvePicker = QtWidgets.QListWidget(Form)
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.easingCurvePicker.sizePolicy().hasHeightForWidth())
self.easingCurvePicker.setSizePolicy(sizePolicy)
self.easingCurvePicker.setMaximumSize(QtCore.QSize(16777215, 120))
self.easingCurvePicker.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
- self.easingCurvePicker.setMovement(QtGui.QListView.Static)
+ self.easingCurvePicker.setMovement(QtWidgets.QListView.Static)
self.easingCurvePicker.setProperty("isWrapping", False)
- self.easingCurvePicker.setViewMode(QtGui.QListView.IconMode)
+ self.easingCurvePicker.setViewMode(QtWidgets.QListView.IconMode)
self.easingCurvePicker.setSelectionRectVisible(False)
self.easingCurvePicker.setObjectName("easingCurvePicker")
self.gridLayout.addWidget(self.easingCurvePicker, 0, 0, 1, 2)
- self.verticalLayout = QtGui.QVBoxLayout()
+ self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
- self.groupBox_2 = QtGui.QGroupBox(Form)
+ self.groupBox_2 = QtWidgets.QGroupBox(Form)
self.groupBox_2.setObjectName("groupBox_2")
- self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox_2)
+ self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.groupBox_2)
self.verticalLayout_2.setObjectName("verticalLayout_2")
- self.lineRadio = QtGui.QRadioButton(self.groupBox_2)
+ self.lineRadio = QtWidgets.QRadioButton(self.groupBox_2)
self.lineRadio.setChecked(True)
self.lineRadio.setObjectName("lineRadio")
- self.buttonGroup = QtGui.QButtonGroup(Form)
+ self.buttonGroup = QtWidgets.QButtonGroup(Form)
self.buttonGroup.setObjectName("buttonGroup")
self.buttonGroup.addButton(self.lineRadio)
self.verticalLayout_2.addWidget(self.lineRadio)
- self.circleRadio = QtGui.QRadioButton(self.groupBox_2)
+ self.circleRadio = QtWidgets.QRadioButton(self.groupBox_2)
self.circleRadio.setObjectName("circleRadio")
self.buttonGroup.addButton(self.circleRadio)
self.verticalLayout_2.addWidget(self.circleRadio)
self.verticalLayout.addWidget(self.groupBox_2)
- self.groupBox = QtGui.QGroupBox(Form)
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred)
+ self.groupBox = QtWidgets.QGroupBox(Form)
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth())
self.groupBox.setSizePolicy(sizePolicy)
self.groupBox.setObjectName("groupBox")
- self.formLayout = QtGui.QFormLayout(self.groupBox)
- self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
+ self.formLayout = QtWidgets.QFormLayout(self.groupBox)
+ self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout.setObjectName("formLayout")
- self.label = QtGui.QLabel(self.groupBox)
+ self.label = QtWidgets.QLabel(self.groupBox)
self.label.setObjectName("label")
- self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.label)
- self.periodSpinBox = QtGui.QDoubleSpinBox(self.groupBox)
+ self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label)
+ self.periodSpinBox = QtWidgets.QDoubleSpinBox(self.groupBox)
self.periodSpinBox.setEnabled(False)
self.periodSpinBox.setMinimum(-1.0)
self.periodSpinBox.setSingleStep(0.1)
self.periodSpinBox.setProperty("value", -1.0)
self.periodSpinBox.setObjectName("periodSpinBox")
- self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.periodSpinBox)
- self.label_2 = QtGui.QLabel(self.groupBox)
+ self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.periodSpinBox)
+ self.label_2 = QtWidgets.QLabel(self.groupBox)
self.label_2.setObjectName("label_2")
- self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.label_2)
- self.amplitudeSpinBox = QtGui.QDoubleSpinBox(self.groupBox)
+ self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2)
+ self.amplitudeSpinBox = QtWidgets.QDoubleSpinBox(self.groupBox)
self.amplitudeSpinBox.setEnabled(False)
self.amplitudeSpinBox.setMinimum(-1.0)
self.amplitudeSpinBox.setSingleStep(0.1)
self.amplitudeSpinBox.setProperty("value", -1.0)
self.amplitudeSpinBox.setObjectName("amplitudeSpinBox")
- self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.amplitudeSpinBox)
- self.label_3 = QtGui.QLabel(self.groupBox)
+ self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.amplitudeSpinBox)
+ self.label_3 = QtWidgets.QLabel(self.groupBox)
self.label_3.setObjectName("label_3")
- self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.label_3)
- self.overshootSpinBox = QtGui.QDoubleSpinBox(self.groupBox)
+ self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_3)
+ self.overshootSpinBox = QtWidgets.QDoubleSpinBox(self.groupBox)
self.overshootSpinBox.setEnabled(False)
self.overshootSpinBox.setMinimum(-1.0)
self.overshootSpinBox.setSingleStep(0.1)
self.overshootSpinBox.setProperty("value", -1.0)
self.overshootSpinBox.setObjectName("overshootSpinBox")
- self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.overshootSpinBox)
+ self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.overshootSpinBox)
self.verticalLayout.addWidget(self.groupBox)
- spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+ spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
self.gridLayout.addLayout(self.verticalLayout, 1, 0, 1, 1)
- self.graphicsView = QtGui.QGraphicsView(Form)
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
+ self.graphicsView = QtWidgets.QGraphicsView(Form)
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.graphicsView.sizePolicy().hasHeightForWidth())
@@ -104,12 +104,12 @@ class Ui_Form(object):
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
- Form.setWindowTitle(QtGui.QApplication.translate("Form", "Easing curves", None, QtGui.QApplication.UnicodeUTF8))
- self.groupBox_2.setTitle(QtGui.QApplication.translate("Form", "Path type", None, QtGui.QApplication.UnicodeUTF8))
- self.lineRadio.setText(QtGui.QApplication.translate("Form", "Line", None, QtGui.QApplication.UnicodeUTF8))
- self.circleRadio.setText(QtGui.QApplication.translate("Form", "Circle", None, QtGui.QApplication.UnicodeUTF8))
- self.groupBox.setTitle(QtGui.QApplication.translate("Form", "Properties", None, QtGui.QApplication.UnicodeUTF8))
- self.label.setText(QtGui.QApplication.translate("Form", "Period", None, QtGui.QApplication.UnicodeUTF8))
- self.label_2.setText(QtGui.QApplication.translate("Form", "Amplitude", None, QtGui.QApplication.UnicodeUTF8))
- self.label_3.setText(QtGui.QApplication.translate("Form", "Overshoot", None, QtGui.QApplication.UnicodeUTF8))
+ Form.setWindowTitle(QtWidgets.QApplication.translate("Form", "Easing curves", None))
+ self.groupBox_2.setTitle(QtWidgets.QApplication.translate("Form", "Path type", None))
+ self.lineRadio.setText(QtWidgets.QApplication.translate("Form", "Line", None))
+ self.circleRadio.setText(QtWidgets.QApplication.translate("Form", "Circle", None))
+ self.groupBox.setTitle(QtWidgets.QApplication.translate("Form", "Properties", None))
+ self.label.setText(QtWidgets.QApplication.translate("Form", "Period", None))
+ self.label_2.setText(QtWidgets.QApplication.translate("Form", "Amplitude", None))
+ self.label_3.setText(QtWidgets.QApplication.translate("Form", "Overshoot", None))
diff --git a/examples/animation/states/states.py b/examples/animation/states/states.py
index b089cb6..e812e9f 100755
--- a/examples/animation/states/states.py
+++ b/examples/animation/states/states.py
@@ -3,10 +3,10 @@
#############################################################################
##
## Copyright (C) 2010 Riverbank Computing Limited.
-## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-## All rights reserved.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the examples of PyQt.
+## This file is part of the PySide examples of the Qt Toolkit.
##
## $QT_BEGIN_LICENSE:BSD$
## You may use this file under the terms of the BSD license as follows:
@@ -20,10 +20,10 @@
## notice, this list of conditions and the following disclaimer in
## the documentation and/or other materials provided with the
## distribution.
-## * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-## the names of its contributors may be used to endorse or promote
-## products derived from this software without specific prior written
-## permission.
+## * 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
@@ -36,19 +36,17 @@
## 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$
##
#############################################################################
-# This file was taken from the PyQt examples,
-# which are adapted from the original C++ Qt examples.
-
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
import states_rc
-class Pixmap(QtGui.QGraphicsObject):
+class Pixmap(QtWidgets.QGraphicsObject):
def __init__(self, pix):
super(Pixmap, self).__init__()
@@ -65,38 +63,38 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
# Text edit and button.
- edit = QtGui.QTextEdit()
+ edit = QtWidgets.QTextEdit()
edit.setText("asdf lkjha yuoiqwe asd iuaysd u iasyd uiy "
"asdf lkjha yuoiqwe asd iuaysd u iasyd uiy "
"asdf lkjha yuoiqwe asd iuaysd u iasyd uiy "
"asdf lkjha yuoiqwe asd iuaysd u iasyd uiy!")
- button = QtGui.QPushButton()
- buttonProxy = QtGui.QGraphicsProxyWidget()
+ button = QtWidgets.QPushButton()
+ buttonProxy = QtWidgets.QGraphicsProxyWidget()
buttonProxy.setWidget(button)
- editProxy = QtGui.QGraphicsProxyWidget()
+ editProxy = QtWidgets.QGraphicsProxyWidget()
editProxy.setWidget(edit)
- box = QtGui.QGroupBox()
+ box = QtWidgets.QGroupBox()
box.setFlat(True)
box.setTitle("Options")
- layout2 = QtGui.QVBoxLayout()
+ layout2 = QtWidgets.QVBoxLayout()
box.setLayout(layout2)
- layout2.addWidget(QtGui.QRadioButton("Herring"))
- layout2.addWidget(QtGui.QRadioButton("Blue Parrot"))
- layout2.addWidget(QtGui.QRadioButton("Petunias"))
+ layout2.addWidget(QtWidgets.QRadioButton("Herring"))
+ layout2.addWidget(QtWidgets.QRadioButton("Blue Parrot"))
+ layout2.addWidget(QtWidgets.QRadioButton("Petunias"))
layout2.addStretch()
- boxProxy = QtGui.QGraphicsProxyWidget()
+ boxProxy = QtWidgets.QGraphicsProxyWidget()
boxProxy.setWidget(box)
# Parent widget.
- widget = QtGui.QGraphicsWidget()
- layout = QtGui.QGraphicsLinearLayout(QtCore.Qt.Vertical, widget)
+ widget = QtWidgets.QGraphicsWidget()
+ layout = QtWidgets.QGraphicsLinearLayout(QtCore.Qt.Vertical, widget)
layout.addItem(editProxy)
layout.addItem(buttonProxy)
widget.setLayout(layout)
@@ -108,7 +106,7 @@ if __name__ == '__main__':
p5 = Pixmap(QtGui.QPixmap(':/help-browser.png'))
p6 = Pixmap(QtGui.QPixmap(':/kchart.png'))
- scene = QtGui.QGraphicsScene(0, 0, 400, 300)
+ scene = QtWidgets.QGraphicsScene(0, 0, 400, 300)
scene.setBackgroundBrush(scene.palette().window())
scene.addItem(widget)
scene.addItem(boxProxy)
@@ -261,7 +259,7 @@ if __name__ == '__main__':
machine.start()
- view = QtGui.QGraphicsView(scene)
+ view = QtWidgets.QGraphicsView(scene)
view.show()
sys.exit(app.exec_())
diff --git a/examples/dialogs/classwizard/classwizard.py b/examples/dialogs/classwizard/classwizard.py
index a5260c4..ff7677f 100755
--- a/examples/dialogs/classwizard/classwizard.py
+++ b/examples/dialogs/classwizard/classwizard.py
@@ -1,16 +1,52 @@
#!/usr/bin/env python
-# This is only needed for Python v2 but is harmless for Python v3.
-#import sip
-#sip.setapi('QString', 2)
-#sip.setapi('QVariant', 2)
-
-from PySide2 import QtCore, QtGui
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui, QtWidgets
import classwizard_rc
-class ClassWizard(QtGui.QWizard):
+class ClassWizard(QtWidgets.QWizard):
def __init__(self, parent=None):
super(ClassWizard, self).__init__(parent)
@@ -20,9 +56,9 @@ class ClassWizard(QtGui.QWizard):
self.addPage(OutputFilesPage())
self.addPage(ConclusionPage())
- self.setPixmap(QtGui.QWizard.BannerPixmap,
+ self.setPixmap(QtWidgets.QWizard.BannerPixmap,
QtGui.QPixmap(':/images/banner.png'))
- self.setPixmap(QtGui.QWizard.BackgroundPixmap,
+ self.setPixmap(QtWidgets.QWizard.BackgroundPixmap,
QtGui.QPixmap(':/images/background.png'))
self.setWindowTitle("Class Wizard")
@@ -88,7 +124,7 @@ class ClassWizard(QtGui.QWizard):
headerFile = QtCore.QFile(outputDir + '/' + header)
if not headerFile.open(QtCore.QFile.WriteOnly | QtCore.QFile.Text):
- QtGui.QMessageBox.warning(None, "Class Wizard",
+ QtWidgets.QMessageBox.warning(None, "Class Wizard",
"Cannot write file %s:\n%s" % (headerFile.fileName(), headerFile.errorString()))
return
@@ -141,7 +177,7 @@ class ClassWizard(QtGui.QWizard):
implementationFile = QtCore.QFile(outputDir + '/' + implementation)
if not implementationFile.open(QtCore.QFile.WriteOnly | QtCore.QFile.Text):
- QtGui.QMessageBox.warning(None, "Class Wizard",
+ QtWidgets.QMessageBox.warning(None, "Class Wizard",
"Cannot write file %s:\n%s" % (implementationFile.fileName(), implementationFile.errorString()))
return
@@ -150,52 +186,52 @@ class ClassWizard(QtGui.QWizard):
super(ClassWizard, self).accept()
-class IntroPage(QtGui.QWizardPage):
+class IntroPage(QtWidgets.QWizardPage):
def __init__(self, parent=None):
super(IntroPage, self).__init__(parent)
self.setTitle("Introduction")
- self.setPixmap(QtGui.QWizard.WatermarkPixmap,
+ self.setPixmap(QtWidgets.QWizard.WatermarkPixmap,
QtGui.QPixmap(':/images/watermark1.png'))
- label = QtGui.QLabel("This wizard will generate a skeleton C++ class "
+ label = QtWidgets.QLabel("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 = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(label)
self.setLayout(layout)
-class ClassInfoPage(QtGui.QWizardPage):
+class ClassInfoPage(QtWidgets.QWizardPage):
def __init__(self, parent=None):
super(ClassInfoPage, self).__init__(parent)
self.setTitle("Class Information")
self.setSubTitle("Specify basic information about the class for "
"which you want to generate skeleton source code files.")
- self.setPixmap(QtGui.QWizard.LogoPixmap,
+ self.setPixmap(QtWidgets.QWizard.LogoPixmap,
QtGui.QPixmap(':/images/logo1.png'))
- classNameLabel = QtGui.QLabel("&Class name:")
- classNameLineEdit = QtGui.QLineEdit()
+ classNameLabel = QtWidgets.QLabel("&Class name:")
+ classNameLineEdit = QtWidgets.QLineEdit()
classNameLabel.setBuddy(classNameLineEdit)
- baseClassLabel = QtGui.QLabel("B&ase class:")
- baseClassLineEdit = QtGui.QLineEdit()
+ baseClassLabel = QtWidgets.QLabel("B&ase class:")
+ baseClassLineEdit = QtWidgets.QLineEdit()
baseClassLabel.setBuddy(baseClassLineEdit)
- qobjectMacroCheckBox = QtGui.QCheckBox("Generate Q_OBJECT &macro")
+ qobjectMacroCheckBox = QtWidgets.QCheckBox("Generate Q_OBJECT &macro")
- groupBox = QtGui.QGroupBox("C&onstructor")
+ groupBox = QtWidgets.QGroupBox("C&onstructor")
- qobjectCtorRadioButton = QtGui.QRadioButton("&QObject-style constructor")
- qwidgetCtorRadioButton = QtGui.QRadioButton("Q&Widget-style constructor")
- defaultCtorRadioButton = QtGui.QRadioButton("&Default constructor")
- copyCtorCheckBox = QtGui.QCheckBox("&Generate copy constructor and operator=")
+ qobjectCtorRadioButton = QtWidgets.QRadioButton("&QObject-style constructor")
+ qwidgetCtorRadioButton = QtWidgets.QRadioButton("Q&Widget-style constructor")
+ defaultCtorRadioButton = QtWidgets.QRadioButton("&Default constructor")
+ copyCtorCheckBox = QtWidgets.QCheckBox("&Generate copy constructor and operator=")
defaultCtorRadioButton.setChecked(True)
@@ -209,14 +245,14 @@ class ClassInfoPage(QtGui.QWizardPage):
self.registerField('defaultCtor', defaultCtorRadioButton)
self.registerField('copyCtor', copyCtorCheckBox)
- groupBoxLayout = QtGui.QVBoxLayout()
+ groupBoxLayout = QtWidgets.QVBoxLayout()
groupBoxLayout.addWidget(qobjectCtorRadioButton)
groupBoxLayout.addWidget(qwidgetCtorRadioButton)
groupBoxLayout.addWidget(defaultCtorRadioButton)
groupBoxLayout.addWidget(copyCtorCheckBox)
groupBox.setLayout(groupBoxLayout)
- layout = QtGui.QGridLayout()
+ layout = QtWidgets.QGridLayout()
layout.addWidget(classNameLabel, 0, 0)
layout.addWidget(classNameLineEdit, 0, 1)
layout.addWidget(baseClassLabel, 1, 0)
@@ -226,31 +262,31 @@ class ClassInfoPage(QtGui.QWizardPage):
self.setLayout(layout)
-class CodeStylePage(QtGui.QWizardPage):
+class CodeStylePage(QtWidgets.QWizardPage):
def __init__(self, parent=None):
super(CodeStylePage, self).__init__(parent)
self.setTitle("Code Style Options")
self.setSubTitle("Choose the formatting of the generated code.")
- self.setPixmap(QtGui.QWizard.LogoPixmap,
+ self.setPixmap(QtWidgets.QWizard.LogoPixmap,
QtGui.QPixmap(':/images/logo2.png'))
- commentCheckBox = QtGui.QCheckBox("&Start generated files with a "
+ commentCheckBox = QtWidgets.QCheckBox("&Start generated files with a "
"comment")
commentCheckBox.setChecked(True)
- protectCheckBox = QtGui.QCheckBox("&Protect header file against "
+ protectCheckBox = QtWidgets.QCheckBox("&Protect header file against "
"multiple inclusions")
protectCheckBox.setChecked(True)
- macroNameLabel = QtGui.QLabel("&Macro name:")
- self.macroNameLineEdit = QtGui.QLineEdit()
+ macroNameLabel = QtWidgets.QLabel("&Macro name:")
+ self.macroNameLineEdit = QtWidgets.QLineEdit()
macroNameLabel.setBuddy(self.macroNameLineEdit)
- self.includeBaseCheckBox = QtGui.QCheckBox("&Include base class "
+ self.includeBaseCheckBox = QtWidgets.QCheckBox("&Include base class "
"definition")
- self.baseIncludeLabel = QtGui.QLabel("Base class include:")
- self.baseIncludeLineEdit = QtGui.QLineEdit()
+ self.baseIncludeLabel = QtWidgets.QLabel("Base class include:")
+ self.baseIncludeLineEdit = QtWidgets.QLineEdit()
self.baseIncludeLabel.setBuddy(self.baseIncludeLineEdit)
protectCheckBox.toggled.connect(macroNameLabel.setEnabled)
@@ -264,7 +300,7 @@ class CodeStylePage(QtGui.QWizardPage):
self.registerField('includeBase', self.includeBaseCheckBox)
self.registerField('baseInclude', self.baseIncludeLineEdit)
- layout = QtGui.QGridLayout()
+ layout = QtWidgets.QGridLayout()
layout.setColumnMinimumWidth(0, 20)
layout.addWidget(commentCheckBox, 0, 0, 1, 3)
layout.addWidget(protectCheckBox, 1, 0, 1, 3)
@@ -295,33 +331,33 @@ class CodeStylePage(QtGui.QWizardPage):
self.baseIncludeLineEdit.setText('"' + baseClass.lower() + '.h"')
-class OutputFilesPage(QtGui.QWizardPage):
+class OutputFilesPage(QtWidgets.QWizardPage):
def __init__(self, parent=None):
super(OutputFilesPage, self).__init__(parent)
self.setTitle("Output Files")
self.setSubTitle("Specify where you want the wizard to put the "
"generated skeleton code.")
- self.setPixmap(QtGui.QWizard.LogoPixmap,
+ self.setPixmap(QtWidgets.QWizard.LogoPixmap,
QtGui.QPixmap(':/images/logo3.png'))
- outputDirLabel = QtGui.QLabel("&Output directory:")
- self.outputDirLineEdit = QtGui.QLineEdit()
+ outputDirLabel = QtWidgets.QLabel("&Output directory:")
+ self.outputDirLineEdit = QtWidgets.QLineEdit()
outputDirLabel.setBuddy(self.outputDirLineEdit)
- headerLabel = QtGui.QLabel("&Header file name:")
- self.headerLineEdit = QtGui.QLineEdit()
+ headerLabel = QtWidgets.QLabel("&Header file name:")
+ self.headerLineEdit = QtWidgets.QLineEdit()
headerLabel.setBuddy(self.headerLineEdit)
- implementationLabel = QtGui.QLabel("&Implementation file name:")
- self.implementationLineEdit = QtGui.QLineEdit()
+ implementationLabel = QtWidgets.QLabel("&Implementation file name:")
+ self.implementationLineEdit = QtWidgets.QLineEdit()
implementationLabel.setBuddy(self.implementationLineEdit)
self.registerField('outputDir*', self.outputDirLineEdit)
self.registerField('header*', self.headerLineEdit)
self.registerField('implementation*', self.implementationLineEdit)
- layout = QtGui.QGridLayout()
+ layout = QtWidgets.QGridLayout()
layout.addWidget(outputDirLabel, 0, 0)
layout.addWidget(self.outputDirLineEdit, 0, 1)
layout.addWidget(headerLabel, 1, 0)
@@ -334,26 +370,26 @@ class OutputFilesPage(QtGui.QWizardPage):
className = self.field('className')
self.headerLineEdit.setText(className.lower() + '.h')
self.implementationLineEdit.setText(className.lower() + '.cpp')
- self.outputDirLineEdit.setText(QtCore.QDir.convertSeparators(QtCore.QDir.tempPath()))
+ self.outputDirLineEdit.setText(QtCore.QDir.toNativeSeparators(QtCore.QDir.tempPath()))
-class ConclusionPage(QtGui.QWizardPage):
+class ConclusionPage(QtWidgets.QWizardPage):
def __init__(self, parent=None):
super(ConclusionPage, self).__init__(parent)
self.setTitle("Conclusion")
- self.setPixmap(QtGui.QWizard.WatermarkPixmap,
+ self.setPixmap(QtWidgets.QWizard.WatermarkPixmap,
QtGui.QPixmap(':/images/watermark2.png'))
- self.label = QtGui.QLabel()
+ self.label = QtWidgets.QLabel()
self.label.setWordWrap(True)
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(self.label)
self.setLayout(layout)
def initializePage(self):
- finishText = self.wizard().buttonText(QtGui.QWizard.FinishButton)
+ finishText = self.wizard().buttonText(QtWidgets.QWizard.FinishButton)
finishText.replace('&', '')
self.label.setText("Click %s to generate the class skeleton." % finishText)
@@ -362,7 +398,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
wizard = ClassWizard()
wizard.show()
sys.exit(app.exec_())
diff --git a/examples/dialogs/extension.py b/examples/dialogs/extension.py
index 8867b58..866e04b 100755
--- a/examples/dialogs/extension.py
+++ b/examples/dialogs/extension.py
@@ -1,60 +1,101 @@
#!/usr/bin/env python
-"""PyQt4 port of the dialogs/extension example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui
-
-
-class FindDialog(QtGui.QDialog):
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/dialogs/extension example from Qt v5.x"""
+
+from PySide2 import QtCore, QtWidgets
+
+
+class FindDialog(QtWidgets.QDialog):
def __init__(self, parent=None):
super(FindDialog, self).__init__(parent)
- label = QtGui.QLabel("Find &what:")
- lineEdit = QtGui.QLineEdit()
+ label = QtWidgets.QLabel("Find &what:")
+ lineEdit = QtWidgets.QLineEdit()
label.setBuddy(lineEdit)
- caseCheckBox = QtGui.QCheckBox("Match &case")
- fromStartCheckBox = QtGui.QCheckBox("Search from &start")
+ caseCheckBox = QtWidgets.QCheckBox("Match &case")
+ fromStartCheckBox = QtWidgets.QCheckBox("Search from &start")
fromStartCheckBox.setChecked(True)
- findButton = QtGui.QPushButton("&Find")
+ findButton = QtWidgets.QPushButton("&Find")
findButton.setDefault(True)
- moreButton = QtGui.QPushButton("&More")
+ moreButton = QtWidgets.QPushButton("&More")
moreButton.setCheckable(True)
moreButton.setAutoDefault(False)
- buttonBox = QtGui.QDialogButtonBox(QtCore.Qt.Vertical)
- buttonBox.addButton(findButton, QtGui.QDialogButtonBox.ActionRole)
- buttonBox.addButton(moreButton, QtGui.QDialogButtonBox.ActionRole)
+ buttonBox = QtWidgets.QDialogButtonBox(QtCore.Qt.Vertical)
+ buttonBox.addButton(findButton, QtWidgets.QDialogButtonBox.ActionRole)
+ buttonBox.addButton(moreButton, QtWidgets.QDialogButtonBox.ActionRole)
- extension = QtGui.QWidget()
+ extension = QtWidgets.QWidget()
- wholeWordsCheckBox = QtGui.QCheckBox("&Whole words")
- backwardCheckBox = QtGui.QCheckBox("Search &backward")
- searchSelectionCheckBox = QtGui.QCheckBox("Search se&lection")
+ wholeWordsCheckBox = QtWidgets.QCheckBox("&Whole words")
+ backwardCheckBox = QtWidgets.QCheckBox("Search &backward")
+ searchSelectionCheckBox = QtWidgets.QCheckBox("Search se&lection")
moreButton.toggled.connect(extension.setVisible)
- extensionLayout = QtGui.QVBoxLayout()
+ extensionLayout = QtWidgets.QVBoxLayout()
extensionLayout.setContentsMargins(0, 0, 0, 0)
extensionLayout.addWidget(wholeWordsCheckBox)
extensionLayout.addWidget(backwardCheckBox)
extensionLayout.addWidget(searchSelectionCheckBox)
extension.setLayout(extensionLayout)
- topLeftLayout = QtGui.QHBoxLayout()
+ topLeftLayout = QtWidgets.QHBoxLayout()
topLeftLayout.addWidget(label)
topLeftLayout.addWidget(lineEdit)
- leftLayout = QtGui.QVBoxLayout()
+ leftLayout = QtWidgets.QVBoxLayout()
leftLayout.addLayout(topLeftLayout)
leftLayout.addWidget(caseCheckBox)
leftLayout.addWidget(fromStartCheckBox)
leftLayout.addStretch(1)
- mainLayout = QtGui.QGridLayout()
- mainLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize)
+ mainLayout = QtWidgets.QGridLayout()
+ mainLayout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
mainLayout.addLayout(leftLayout, 0, 0)
mainLayout.addWidget(buttonBox, 0, 1)
mainLayout.addWidget(extension, 1, 0, 1, 2)
@@ -68,6 +109,6 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
dialog = FindDialog()
sys.exit(dialog.exec_())
diff --git a/examples/dialogs/findfiles.py b/examples/dialogs/findfiles.py
index c3b01ee..cc41033 100755
--- a/examples/dialogs/findfiles.py
+++ b/examples/dialogs/findfiles.py
@@ -1,11 +1,52 @@
#!/usr/bin/env python
-"""PyQt4 port of the dialogs/findfiles example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui
-
-
-class Window(QtGui.QDialog):
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/dialogs/findfiles example from Qt v5.x"""
+
+from PySide2 import QtCore, QtGui, QtWidgets
+
+
+class Window(QtWidgets.QDialog):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
@@ -16,18 +57,18 @@ class Window(QtGui.QDialog):
self.textComboBox = self.createComboBox()
self.directoryComboBox = self.createComboBox(QtCore.QDir.currentPath())
- fileLabel = QtGui.QLabel("Named:")
- textLabel = QtGui.QLabel("Containing text:")
- directoryLabel = QtGui.QLabel("In directory:")
- self.filesFoundLabel = QtGui.QLabel()
+ fileLabel = QtWidgets.QLabel("Named:")
+ textLabel = QtWidgets.QLabel("Containing text:")
+ directoryLabel = QtWidgets.QLabel("In directory:")
+ self.filesFoundLabel = QtWidgets.QLabel()
self.createFilesTable()
- buttonsLayout = QtGui.QHBoxLayout()
+ buttonsLayout = QtWidgets.QHBoxLayout()
buttonsLayout.addStretch()
buttonsLayout.addWidget(self.findButton)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(fileLabel, 0, 0)
mainLayout.addWidget(self.fileComboBox, 0, 1, 1, 2)
mainLayout.addWidget(textLabel, 1, 0)
@@ -44,7 +85,7 @@ class Window(QtGui.QDialog):
self.resize(500, 300)
def browse(self):
- directory = QtGui.QFileDialog.getExistingDirectory(self, "Find Files",
+ directory = QtWidgets.QFileDialog.getExistingDirectory(self, "Find Files",
QtCore.QDir.currentPath())
if directory:
@@ -80,7 +121,7 @@ class Window(QtGui.QDialog):
self.showFiles(files)
def findFiles(self, files, text):
- progressDialog = QtGui.QProgressDialog(self)
+ progressDialog = QtWidgets.QProgressDialog(self)
progressDialog.setCancelButtonText("&Cancel")
progressDialog.setRange(0, len(files))
@@ -91,7 +132,7 @@ class Window(QtGui.QDialog):
for i in range(len(files)):
progressDialog.setValue(i)
progressDialog.setLabelText("Searching file number %d of %d..." % (i, len(files)))
- QtGui.qApp.processEvents()
+ QtCore.qApp.processEvents()
if progressDialog.wasCanceled():
break
@@ -117,9 +158,9 @@ class Window(QtGui.QDialog):
file = QtCore.QFile(self.currentDir.absoluteFilePath(fn))
size = QtCore.QFileInfo(file).size()
- fileNameItem = QtGui.QTableWidgetItem(fn)
+ fileNameItem = QtWidgets.QTableWidgetItem(fn)
fileNameItem.setFlags(fileNameItem.flags() ^ QtCore.Qt.ItemIsEditable)
- sizeItem = QtGui.QTableWidgetItem("%d KB" % (int((size + 1023) / 1024)))
+ sizeItem = QtWidgets.QTableWidgetItem("%d KB" % (int((size + 1023) / 1024)))
sizeItem.setTextAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight)
sizeItem.setFlags(sizeItem.flags() ^ QtCore.Qt.ItemIsEditable)
@@ -131,24 +172,24 @@ class Window(QtGui.QDialog):
self.filesFoundLabel.setText("%d file(s) found (Double click on a file to open it)" % len(files))
def createButton(self, text, member):
- button = QtGui.QPushButton(text)
+ button = QtWidgets.QPushButton(text)
button.clicked.connect(member)
return button
def createComboBox(self, text=""):
- comboBox = QtGui.QComboBox()
+ comboBox = QtWidgets.QComboBox()
comboBox.setEditable(True)
comboBox.addItem(text)
- comboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
- QtGui.QSizePolicy.Preferred)
+ comboBox.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
+ QtWidgets.QSizePolicy.Preferred)
return comboBox
def createFilesTable(self):
- self.filesTable = QtGui.QTableWidget(0, 2)
- self.filesTable.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
+ self.filesTable = QtWidgets.QTableWidget(0, 2)
+ self.filesTable.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
self.filesTable.setHorizontalHeaderLabels(("File Name", "Size"))
- self.filesTable.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.Stretch)
+ self.filesTable.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
self.filesTable.verticalHeader().hide()
self.filesTable.setShowGrid(False)
@@ -164,7 +205,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
diff --git a/examples/dialogs/standarddialogs.py b/examples/dialogs/standarddialogs.py
index 256ba40..6016c64 100755
--- a/examples/dialogs/standarddialogs.py
+++ b/examples/dialogs/standarddialogs.py
@@ -1,16 +1,53 @@
#!/usr/bin/env python
-"""PyQt4 port of the dialogs/standarddialogs example from Qt v4.x"""
-
-# This is only needed for Python v2 but is harmless for Python v3.
-#import sip
-#sip.setapi('QString', 2)
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/dialogs/standarddialogs example from Qt v5.x"""
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class Dialog(QtGui.QDialog):
+class Dialog(QtWidgets.QDialog):
MESSAGE = "<p>Message boxes have a caption, a text, and up to three " \
"buttons, each with standard or custom texts.</p>" \
"<p>Click a button to close the message box. Pressing the Esc " \
@@ -21,69 +58,69 @@ class Dialog(QtGui.QDialog):
self.openFilesPath = ''
- self.errorMessageDialog = QtGui.QErrorMessage(self)
+ self.errorMessageDialog = QtWidgets.QErrorMessage(self)
- frameStyle = QtGui.QFrame.Sunken | QtGui.QFrame.Panel
+ frameStyle = QtWidgets.QFrame.Sunken | QtWidgets.QFrame.Panel
- self.integerLabel = QtGui.QLabel()
+ self.integerLabel = QtWidgets.QLabel()
self.integerLabel.setFrameStyle(frameStyle)
- self.integerButton = QtGui.QPushButton("QInputDialog.get&Integer()")
+ self.integerButton = QtWidgets.QPushButton("QInputDialog.get&Integer()")
- self.doubleLabel = QtGui.QLabel()
+ self.doubleLabel = QtWidgets.QLabel()
self.doubleLabel.setFrameStyle(frameStyle)
- self.doubleButton = QtGui.QPushButton("QInputDialog.get&Double()")
+ self.doubleButton = QtWidgets.QPushButton("QInputDialog.get&Double()")
- self.itemLabel = QtGui.QLabel()
+ self.itemLabel = QtWidgets.QLabel()
self.itemLabel.setFrameStyle(frameStyle)
- self.itemButton = QtGui.QPushButton("QInputDialog.getIte&m()")
+ self.itemButton = QtWidgets.QPushButton("QInputDialog.getIte&m()")
- self.textLabel = QtGui.QLabel()
+ self.textLabel = QtWidgets.QLabel()
self.textLabel.setFrameStyle(frameStyle)
- self.textButton = QtGui.QPushButton("QInputDialog.get&Text()")
+ self.textButton = QtWidgets.QPushButton("QInputDialog.get&Text()")
- self.colorLabel = QtGui.QLabel()
+ self.colorLabel = QtWidgets.QLabel()
self.colorLabel.setFrameStyle(frameStyle)
- self.colorButton = QtGui.QPushButton("QColorDialog.get&Color()")
+ self.colorButton = QtWidgets.QPushButton("QColorDialog.get&Color()")
- self.fontLabel = QtGui.QLabel()
+ self.fontLabel = QtWidgets.QLabel()
self.fontLabel.setFrameStyle(frameStyle)
- self.fontButton = QtGui.QPushButton("QFontDialog.get&Font()")
+ self.fontButton = QtWidgets.QPushButton("QFontDialog.get&Font()")
- self.directoryLabel = QtGui.QLabel()
+ self.directoryLabel = QtWidgets.QLabel()
self.directoryLabel.setFrameStyle(frameStyle)
- self.directoryButton = QtGui.QPushButton("QFileDialog.getE&xistingDirectory()")
+ self.directoryButton = QtWidgets.QPushButton("QFileDialog.getE&xistingDirectory()")
- self.openFileNameLabel = QtGui.QLabel()
+ self.openFileNameLabel = QtWidgets.QLabel()
self.openFileNameLabel.setFrameStyle(frameStyle)
- self.openFileNameButton = QtGui.QPushButton("QFileDialog.get&OpenFileName()")
+ self.openFileNameButton = QtWidgets.QPushButton("QFileDialog.get&OpenFileName()")
- self.openFileNamesLabel = QtGui.QLabel()
+ self.openFileNamesLabel = QtWidgets.QLabel()
self.openFileNamesLabel.setFrameStyle(frameStyle)
- self.openFileNamesButton = QtGui.QPushButton("QFileDialog.&getOpenFileNames()")
+ self.openFileNamesButton = QtWidgets.QPushButton("QFileDialog.&getOpenFileNames()")
- self.saveFileNameLabel = QtGui.QLabel()
+ self.saveFileNameLabel = QtWidgets.QLabel()
self.saveFileNameLabel.setFrameStyle(frameStyle)
- self.saveFileNameButton = QtGui.QPushButton("QFileDialog.get&SaveFileName()")
+ self.saveFileNameButton = QtWidgets.QPushButton("QFileDialog.get&SaveFileName()")
- self.criticalLabel = QtGui.QLabel()
+ self.criticalLabel = QtWidgets.QLabel()
self.criticalLabel.setFrameStyle(frameStyle)
- self.criticalButton = QtGui.QPushButton("QMessageBox.critica&l()")
+ self.criticalButton = QtWidgets.QPushButton("QMessageBox.critica&l()")
- self.informationLabel = QtGui.QLabel()
+ self.informationLabel = QtWidgets.QLabel()
self.informationLabel.setFrameStyle(frameStyle)
- self.informationButton = QtGui.QPushButton("QMessageBox.i&nformation()")
+ self.informationButton = QtWidgets.QPushButton("QMessageBox.i&nformation()")
- self.questionLabel = QtGui.QLabel()
+ self.questionLabel = QtWidgets.QLabel()
self.questionLabel.setFrameStyle(frameStyle)
- self.questionButton = QtGui.QPushButton("QMessageBox.&question()")
+ self.questionButton = QtWidgets.QPushButton("QMessageBox.&question()")
- self.warningLabel = QtGui.QLabel()
+ self.warningLabel = QtWidgets.QLabel()
self.warningLabel.setFrameStyle(frameStyle)
- self.warningButton = QtGui.QPushButton("QMessageBox.&warning()")
+ self.warningButton = QtWidgets.QPushButton("QMessageBox.&warning()")
- self.errorLabel = QtGui.QLabel()
+ self.errorLabel = QtWidgets.QLabel()
self.errorLabel.setFrameStyle(frameStyle)
- self.errorButton = QtGui.QPushButton("QErrorMessage.show&M&essage()")
+ self.errorButton = QtWidgets.QPushButton("QErrorMessage.show&M&essage()")
self.integerButton.clicked.connect(self.setInteger)
self.doubleButton.clicked.connect(self.setDouble)
@@ -101,13 +138,13 @@ class Dialog(QtGui.QDialog):
self.warningButton.clicked.connect(self.warningMessage)
self.errorButton.clicked.connect(self.errorMessage)
- self.native = QtGui.QCheckBox()
+ self.native = QtWidgets.QCheckBox()
self.native.setText("Use native file dialog.")
self.native.setChecked(True)
if sys.platform not in ("win32", "darwin"):
self.native.hide()
- layout = QtGui.QGridLayout()
+ layout = QtWidgets.QGridLayout()
layout.setColumnStretch(1, 1)
layout.setColumnMinimumWidth(1, 250)
layout.addWidget(self.integerButton, 0, 0)
@@ -146,13 +183,13 @@ class Dialog(QtGui.QDialog):
self.setWindowTitle("Standard Dialogs")
def setInteger(self):
- i, ok = QtGui.QInputDialog.getInteger(self,
+ i, ok = QtWidgets.QInputDialog.getInt(self,
"QInputDialog.getInteger()", "Percentage:", 25, 0, 100, 1)
if ok:
self.integerLabel.setText("%d%%" % i)
def setDouble(self):
- d, ok = QtGui.QInputDialog.getDouble(self, "QInputDialog.getDouble()",
+ d, ok = QtWidgets.QInputDialog.getDouble(self, "QInputDialog.getDouble()",
"Amount:", 37.56, -10000, 10000, 2)
if ok:
self.doubleLabel.setText("$%g" % d)
@@ -160,44 +197,44 @@ class Dialog(QtGui.QDialog):
def setItem(self):
items = ("Spring", "Summer", "Fall", "Winter")
- item, ok = QtGui.QInputDialog.getItem(self, "QInputDialog.getItem()",
+ item, ok = QtWidgets.QInputDialog.getItem(self, "QInputDialog.getItem()",
"Season:", items, 0, False)
if ok and item:
self.itemLabel.setText(item)
def setText(self):
- text, ok = QtGui.QInputDialog.getText(self, "QInputDialog.getText()",
- "User name:", QtGui.QLineEdit.Normal,
+ text, ok = QtWidgets.QInputDialog.getText(self, "QInputDialog.getText()",
+ "User name:", QtWidgets.QLineEdit.Normal,
QtCore.QDir.home().dirName())
if ok and text != '':
self.textLabel.setText(text)
def setColor(self):
- color = QtGui.QColorDialog.getColor(QtCore.Qt.green, self)
+ color = QtWidgets.QColorDialog.getColor(QtCore.Qt.green, self)
if color.isValid():
self.colorLabel.setText(color.name())
self.colorLabel.setPalette(QtGui.QPalette(color))
self.colorLabel.setAutoFillBackground(True)
def setFont(self):
- font, ok = QtGui.QFontDialog.getFont(QtGui.QFont(self.fontLabel.text()), self)
+ font, ok = QtWidgets.QFontDialog.getFont(QtGui.QFont(self.fontLabel.text()), self)
if ok:
self.fontLabel.setText(font.key())
self.fontLabel.setFont(font)
def setExistingDirectory(self):
- options = QtGui.QFileDialog.DontResolveSymlinks | QtGui.QFileDialog.ShowDirsOnly
- directory = QtGui.QFileDialog.getExistingDirectory(self,
+ options = QtWidgets.QFileDialog.DontResolveSymlinks | QtWidgets.QFileDialog.ShowDirsOnly
+ directory = QtWidgets.QFileDialog.getExistingDirectory(self,
"QFileDialog.getExistingDirectory()",
self.directoryLabel.text(), options)
if directory:
self.directoryLabel.setText(directory)
def setOpenFileName(self):
- options = QtGui.QFileDialog.Options()
+ options = QtWidgets.QFileDialog.Options()
if not self.native.isChecked():
- options |= QtGui.QFileDialog.DontUseNativeDialog
- fileName, filtr = QtGui.QFileDialog.getOpenFileName(self,
+ options |= QtWidgets.QFileDialog.DontUseNativeDialog
+ fileName, filtr = QtWidgets.QFileDialog.getOpenFileName(self,
"QFileDialog.getOpenFileName()",
self.openFileNameLabel.text(),
"All Files (*);;Text Files (*.txt)", "", options)
@@ -205,10 +242,10 @@ class Dialog(QtGui.QDialog):
self.openFileNameLabel.setText(fileName)
def setOpenFileNames(self):
- options = QtGui.QFileDialog.Options()
+ options = QtWidgets.QFileDialog.Options()
if not self.native.isChecked():
- options |= QtGui.QFileDialog.DontUseNativeDialog
- files, filtr = QtGui.QFileDialog.getOpenFileNames(self,
+ options |= QtWidgets.QFileDialog.DontUseNativeDialog
+ files, filtr = QtWidgets.QFileDialog.getOpenFileNames(self,
"QFileDialog.getOpenFileNames()", self.openFilesPath,
"All Files (*);;Text Files (*.txt)", "", options)
if files:
@@ -216,10 +253,10 @@ class Dialog(QtGui.QDialog):
self.openFileNamesLabel.setText("[%s]" % ', '.join(files))
def setSaveFileName(self):
- options = QtGui.QFileDialog.Options()
+ options = QtWidgets.QFileDialog.Options()
if not self.native.isChecked():
- options |= QtGui.QFileDialog.DontUseNativeDialog
- fileName, filtr = QtGui.QFileDialog.getSaveFileName(self,
+ options |= QtWidgets.QFileDialog.DontUseNativeDialog
+ fileName, filtr = QtWidgets.QFileDialog.getSaveFileName(self,
"QFileDialog.getSaveFileName()",
self.saveFileNameLabel.text(),
"All Files (*);;Text Files (*.txt)", "", options)
@@ -227,42 +264,42 @@ class Dialog(QtGui.QDialog):
self.saveFileNameLabel.setText(fileName)
def criticalMessage(self):
- reply = QtGui.QMessageBox.critical(self, "QMessageBox.critical()",
+ reply = QtWidgets.QMessageBox.critical(self, "QMessageBox.critical()",
Dialog.MESSAGE,
- QtGui.QMessageBox.Abort | QtGui.QMessageBox.Retry | QtGui.QMessageBox.Ignore)
- if reply == QtGui.QMessageBox.Abort:
+ QtWidgets.QMessageBox.Abort | QtWidgets.QMessageBox.Retry | QtWidgets.QMessageBox.Ignore)
+ if reply == QtWidgets.QMessageBox.Abort:
self.criticalLabel.setText("Abort")
- elif reply == QtGui.QMessageBox.Retry:
+ elif reply == QtWidgets.QMessageBox.Retry:
self.criticalLabel.setText("Retry")
else:
self.criticalLabel.setText("Ignore")
def informationMessage(self):
- reply = QtGui.QMessageBox.information(self,
+ reply = QtWidgets.QMessageBox.information(self,
"QMessageBox.information()", Dialog.MESSAGE)
- if reply == QtGui.QMessageBox.Ok:
+ if reply == QtWidgets.QMessageBox.Ok:
self.informationLabel.setText("OK")
else:
self.informationLabel.setText("Escape")
def questionMessage(self):
- reply = QtGui.QMessageBox.question(self, "QMessageBox.question()",
+ reply = QtWidgets.QMessageBox.question(self, "QMessageBox.question()",
Dialog.MESSAGE,
- QtGui.QMessageBox.Yes | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel)
- if reply == QtGui.QMessageBox.Yes:
+ QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Cancel)
+ if reply == QtWidgets.QMessageBox.Yes:
self.questionLabel.setText("Yes")
- elif reply == QtGui.QMessageBox.No:
+ elif reply == QtWidgets.QMessageBox.No:
self.questionLabel.setText("No")
else:
self.questionLabel.setText("Cancel")
def warningMessage(self):
- msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Warning,
+ msgBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning,
"QMessageBox.warning()", Dialog.MESSAGE,
- QtGui.QMessageBox.NoButton, self)
- msgBox.addButton("Save &Again", QtGui.QMessageBox.AcceptRole)
- msgBox.addButton("&Continue", QtGui.QMessageBox.RejectRole)
- if msgBox.exec_() == QtGui.QMessageBox.AcceptRole:
+ QtWidgets.QMessageBox.NoButton, self)
+ msgBox.addButton("Save &Again", QtWidgets.QMessageBox.AcceptRole)
+ msgBox.addButton("&Continue", QtWidgets.QMessageBox.RejectRole)
+ if msgBox.exec_() == QtWidgets.QMessageBox.AcceptRole:
self.warningLabel.setText("Save Again")
else:
self.warningLabel.setText("Continue")
@@ -278,6 +315,6 @@ class Dialog(QtGui.QDialog):
if __name__ == '__main__':
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
dialog = Dialog()
sys.exit(dialog.exec_())
diff --git a/examples/dialogs/trivialwizard.py b/examples/dialogs/trivialwizard.py
index 608a1af..64a2587 100755
--- a/examples/dialogs/trivialwizard.py
+++ b/examples/dialogs/trivialwizard.py
@@ -1,19 +1,60 @@
#!/usr/bin/env python
-"""PyQt4 port of the dialogs/trivialwizard example from Qt v4.x"""
-
-from PySide2 import QtGui
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/dialogs/trivialwizard example from Qt v5.x"""
+
+from PySide2 import QtWidgets
def createIntroPage():
- page = QtGui.QWizardPage()
+ page = QtWidgets.QWizardPage()
page.setTitle("Introduction")
- label = QtGui.QLabel("This wizard will help you register your copy of "
+ label = QtWidgets.QLabel("This wizard will help you register your copy of "
"Super Product Two.")
label.setWordWrap(True)
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(label)
page.setLayout(layout)
@@ -21,17 +62,17 @@ def createIntroPage():
def createRegistrationPage():
- page = QtGui.QWizardPage()
+ page = QtWidgets.QWizardPage()
page.setTitle("Registration")
page.setSubTitle("Please fill both fields.")
- nameLabel = QtGui.QLabel("Name:")
- nameLineEdit = QtGui.QLineEdit()
+ nameLabel = QtWidgets.QLabel("Name:")
+ nameLineEdit = QtWidgets.QLineEdit()
- emailLabel = QtGui.QLabel("Email address:")
- emailLineEdit = QtGui.QLineEdit()
+ emailLabel = QtWidgets.QLabel("Email address:")
+ emailLineEdit = QtWidgets.QLineEdit()
- layout = QtGui.QGridLayout()
+ layout = QtWidgets.QGridLayout()
layout.addWidget(nameLabel, 0, 0)
layout.addWidget(nameLineEdit, 0, 1)
layout.addWidget(emailLabel, 1, 0)
@@ -42,13 +83,13 @@ def createRegistrationPage():
def createConclusionPage():
- page = QtGui.QWizardPage()
+ page = QtWidgets.QWizardPage()
page.setTitle("Conclusion")
- label = QtGui.QLabel("You are now successfully registered. Have a nice day!")
+ label = QtWidgets.QLabel("You are now successfully registered. Have a nice day!")
label.setWordWrap(True)
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(label)
page.setLayout(layout)
@@ -59,9 +100,9 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
- wizard = QtGui.QWizard()
+ wizard = QtWidgets.QWizard()
wizard.addPage(createIntroPage())
wizard.addPage(createRegistrationPage())
wizard.addPage(createConclusionPage())
diff --git a/examples/effects/lighting.py b/examples/effects/lighting.py
index 4650346..efbb747 100755
--- a/examples/effects/lighting.py
+++ b/examples/effects/lighting.py
@@ -1,17 +1,57 @@
#!/usr/bin/env python
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 math
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class Lighting(QtGui.QGraphicsView):
+class Lighting(QtWidgets.QGraphicsView):
def __init__(self, parent=None):
super(Lighting, self).__init__(parent)
self.angle = 0.0
- self.m_scene = QtGui.QGraphicsScene()
+ self.m_scene = QtWidgets.QGraphicsScene()
self.m_lightSource = None
self.m_items = []
@@ -25,7 +65,7 @@ class Lighting(QtGui.QGraphicsView):
timer.start()
self.setRenderHint(QtGui.QPainter.Antialiasing)
- self.setFrameStyle(QtGui.QFrame.NoFrame)
+ self.setFrameStyle(QtWidgets.QFrame.NoFrame)
def setupScene(self):
self.m_scene.setSceneRect(-300, -200, 600, 460)
@@ -56,14 +96,14 @@ class Lighting(QtGui.QGraphicsView):
for i in range(-2, 3):
for j in range(-2, 3):
if (i + j) & 1:
- item = QtGui.QGraphicsEllipseItem(0, 0, 50, 50)
+ item = QtWidgets.QGraphicsEllipseItem(0, 0, 50, 50)
else:
- item = QtGui.QGraphicsRectItem(0, 0, 50, 50)
+ item = QtWidgets.QGraphicsRectItem(0, 0, 50, 50)
item.setPen(QtGui.QPen(QtCore.Qt.black, 1))
item.setBrush(QtGui.QBrush(QtCore.Qt.white))
- effect = QtGui.QGraphicsDropShadowEffect(self)
+ effect = QtWidgets.QGraphicsDropShadowEffect(self)
effect.setBlurRadius(8)
item.setGraphicsEffect(effect)
item.setZValue(1)
@@ -95,7 +135,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
lighting = Lighting()
lighting.setWindowTitle("Lighting and Shadows")
diff --git a/examples/graphicsview/anchorlayout.py b/examples/graphicsview/anchorlayout.py
index b9f11ff..86cea5c 100755
--- a/examples/graphicsview/anchorlayout.py
+++ b/examples/graphicsview/anchorlayout.py
@@ -1,17 +1,57 @@
#!/usr/bin/env python
-
-from PySide2 import QtCore, QtGui
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui, QtWidgets
def createItem(minimum, preferred, maximum, name):
- w = QtGui.QGraphicsProxyWidget()
+ w = QtWidgets.QGraphicsProxyWidget()
- w.setWidget(QtGui.QPushButton(name))
+ w.setWidget(QtWidgets.QPushButton(name))
w.setMinimumSize(minimum)
w.setPreferredSize(preferred)
w.setMaximumSize(maximum)
- w.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
+ w.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
return w
@@ -20,9 +60,9 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
- scene = QtGui.QGraphicsScene()
+ scene = QtWidgets.QGraphicsScene()
scene.setSceneRect(0, 0, 800, 480)
minSize = QtCore.QSizeF(30, 100)
@@ -37,10 +77,10 @@ if __name__ == '__main__':
f = createItem(QtCore.QSizeF(30, 50), QtCore.QSizeF(150, 50), maxSize, "F")
g = createItem(QtCore.QSizeF(30, 50), QtCore.QSizeF(30, 100), maxSize, "G")
- l = QtGui.QGraphicsAnchorLayout()
+ l = QtWidgets.QGraphicsAnchorLayout()
l.setSpacing(0)
- w = QtGui.QGraphicsWidget(None, QtCore.Qt.Window)
+ w = QtWidgets.QGraphicsWidget(None, QtCore.Qt.Window)
w.setPos(20, 20)
w.setLayout(l)
@@ -80,7 +120,7 @@ if __name__ == '__main__':
scene.addItem(w)
scene.setBackgroundBrush(QtCore.Qt.darkGreen)
- view = QtGui.QGraphicsView(scene)
+ view = QtWidgets.QGraphicsView(scene)
view.show()
sys.exit(app.exec_())
diff --git a/examples/graphicsview/collidingmice/collidingmice.py b/examples/graphicsview/collidingmice/collidingmice.py
index 0156650..23f908f 100755
--- a/examples/graphicsview/collidingmice/collidingmice.py
+++ b/examples/graphicsview/collidingmice/collidingmice.py
@@ -1,34 +1,54 @@
#!/usr/bin/env python
-############################################################################
+#############################################################################
##
-## Copyright (C) 2006-2006 Trolltech ASA. All rights reserved.
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
##
-## Licensees holding a valid Qt License Agreement may use this file in
-## accordance with the rights, responsibilities and obligations
-## contained therein. Please consult your licensing agreement or
-## contact sales@trolltech.com if any conditions of this licensing
-## agreement are not clear to you.
+## $QT_BEGIN_LICENSE:BSD$
+## You may use this file under the terms of the BSD license as follows:
##
-## Further information about Qt licensing is available at:
-## http://www.trolltech.com/products/qt/licensing.html or by
-## contacting info@trolltech.com.
+## "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 file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
##
-############################################################################
+## 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 math
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
import mice_rc
-class Mouse(QtGui.QGraphicsItem):
+class Mouse(QtWidgets.QGraphicsItem):
Pi = math.pi
TwoPi = 2.0 * Pi
@@ -46,10 +66,10 @@ class Mouse(QtGui.QGraphicsItem):
self.color = QtGui.QColor(QtCore.qrand() % 256, QtCore.qrand() % 256,
QtCore.qrand() % 256)
- self.rotate(QtCore.qrand() % (360 * 16))
+ self.setTransform(QtGui.QTransform().rotate(QtCore.qrand() % (360 * 16)))
# In the C++ version of this example, this class is also derived from
- # QObject in order to receive timer events. PyQt does not support
+ # QObject in order to receive timer events. PySide2 does not support
# deriving from more than one wrapped class so we just create an
# explicit timer instead.
self.timer = QtCore.QTimer()
@@ -161,7 +181,7 @@ class Mouse(QtGui.QGraphicsItem):
dx = math.sin(self.angle) * 10
self.mouseEyeDirection = [dx / 5, 0.0][QtCore.qAbs(dx / 5) < 1]
- self.rotate(dx)
+ self.setTransform(QtGui.QTransform().rotate(dx))
self.setPos(self.mapToParent(0, -(3 + math.sin(self.speed) * 3)))
@@ -171,12 +191,12 @@ if __name__ == '__main__':
MouseCount = 7
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
QtCore.qsrand(QtCore.QTime(0,0,0).secsTo(QtCore.QTime.currentTime()))
- scene = QtGui.QGraphicsScene()
+ scene = QtWidgets.QGraphicsScene()
scene.setSceneRect(-300, -300, 600, 600)
- scene.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex)
+ scene.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex)
for i in range(MouseCount):
mouse = Mouse()
@@ -184,12 +204,12 @@ if __name__ == '__main__':
math.cos((i * 6.28) / MouseCount) * 200)
scene.addItem(mouse)
- view = QtGui.QGraphicsView(scene)
+ view = QtWidgets.QGraphicsView(scene)
view.setRenderHint(QtGui.QPainter.Antialiasing)
view.setBackgroundBrush(QtGui.QBrush(QtGui.QPixmap(':/images/cheese.jpg')))
- view.setCacheMode(QtGui.QGraphicsView.CacheBackground)
- view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)
- view.setDragMode(QtGui.QGraphicsView.ScrollHandDrag)
+ view.setCacheMode(QtWidgets.QGraphicsView.CacheBackground)
+ view.setViewportUpdateMode(QtWidgets.QGraphicsView.BoundingRectViewportUpdate)
+ view.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag)
view.setWindowTitle("Colliding Mice")
view.resize(400, 300)
view.show()
diff --git a/examples/graphicsview/diagramscene/diagramscene.py b/examples/graphicsview/diagramscene/diagramscene.py
index 51c38b0..ea0af84 100755
--- a/examples/graphicsview/diagramscene/diagramscene.py
+++ b/examples/graphicsview/diagramscene/diagramscene.py
@@ -1,17 +1,54 @@
#!/usr/bin/env python
-# This is only needed for Python v2 but is harmless for Python v3.
-#import sip
-#sip.setapi('QString', 2)
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 math
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
import diagramscene_rc
-class Arrow(QtGui.QGraphicsLineItem):
+class Arrow(QtWidgets.QGraphicsLineItem):
def __init__(self, startItem, endItem, parent=None, scene=None):
super(Arrow, self).__init__(parent, scene)
@@ -19,7 +56,7 @@ class Arrow(QtGui.QGraphicsLineItem):
self.myStartItem = startItem
self.myEndItem = endItem
- self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
+ self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, True)
self.myColor = QtCore.Qt.black
self.setPen(QtGui.QPen(self.myColor, 2, QtCore.Qt.SolidLine,
QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
@@ -101,19 +138,19 @@ class Arrow(QtGui.QGraphicsLineItem):
painter.drawLine(myLine)
-class DiagramTextItem(QtGui.QGraphicsTextItem):
- lostFocus = QtCore.Signal(QtGui.QGraphicsTextItem)
+class DiagramTextItem(QtWidgets.QGraphicsTextItem):
+ lostFocus = QtCore.Signal(QtWidgets.QGraphicsTextItem)
- selectedChange = QtCore.Signal(QtGui.QGraphicsItem)
+ selectedChange = QtCore.Signal(QtWidgets.QGraphicsItem)
def __init__(self, parent=None, scene=None):
super(DiagramTextItem, self).__init__(parent, scene)
- self.setFlag(QtGui.QGraphicsItem.ItemIsMovable)
- self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
+ self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable)
+ self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable)
def itemChange(self, change, value):
- if change == QtGui.QGraphicsItem.ItemSelectedChange:
+ if change == QtWidgets.QGraphicsItem.ItemSelectedChange:
self.selectedChange.emit(self)
return value
@@ -128,7 +165,7 @@ class DiagramTextItem(QtGui.QGraphicsTextItem):
super(DiagramTextItem, self).mouseDoubleClickEvent(event)
-class DiagramItem(QtGui.QGraphicsPolygonItem):
+class DiagramItem(QtWidgets.QGraphicsPolygonItem):
Step, Conditional, StartEnd, Io = range(4)
def __init__(self, diagramType, contextMenu, parent=None, scene=None):
@@ -165,8 +202,8 @@ class DiagramItem(QtGui.QGraphicsPolygonItem):
QtCore.QPointF(-120, -80)])
self.setPolygon(self.myPolygon)
- self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True)
- self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
+ self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True)
+ self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, True)
def removeArrow(self, arrow):
try:
@@ -198,21 +235,21 @@ class DiagramItem(QtGui.QGraphicsPolygonItem):
self.myContextMenu.exec_(event.screenPos())
def itemChange(self, change, value):
- if change == QtGui.QGraphicsItem.ItemPositionChange:
+ if change == QtWidgets.QGraphicsItem.ItemPositionChange:
for arrow in self.arrows:
arrow.updatePosition()
return value
-class DiagramScene(QtGui.QGraphicsScene):
+class DiagramScene(QtWidgets.QGraphicsScene):
InsertItem, InsertLine, InsertText, MoveItem = range(4)
itemInserted = QtCore.Signal(DiagramItem)
- textInserted = QtCore.Signal(QtGui.QGraphicsTextItem)
+ textInserted = QtCore.Signal(QtWidgets.QGraphicsTextItem)
- itemSelected = QtCore.Signal(QtGui.QGraphicsItem)
+ itemSelected = QtCore.Signal(QtWidgets.QGraphicsItem)
def __init__(self, itemMenu, parent=None):
super(DiagramScene, self).__init__(parent)
@@ -278,7 +315,7 @@ class DiagramScene(QtGui.QGraphicsScene):
item.setPos(mouseEvent.scenePos())
self.itemInserted.emit(item)
elif self.myMode == self.InsertLine:
- self.line = QtGui.QGraphicsLineItem(QtCore.QLineF(mouseEvent.scenePos(),
+ self.line = QtWidgets.QGraphicsLineItem(QtCore.QLineF(mouseEvent.scenePos(),
mouseEvent.scenePos()))
self.line.setPen(QtGui.QPen(self.myLineColor, 2))
self.addItem(self.line)
@@ -339,7 +376,7 @@ class DiagramScene(QtGui.QGraphicsScene):
return False
-class MainWindow(QtGui.QMainWindow):
+class MainWindow(QtWidgets.QMainWindow):
InsertTextButton = 10
def __init__(self):
@@ -357,12 +394,12 @@ class MainWindow(QtGui.QMainWindow):
self.createToolbars()
- layout = QtGui.QHBoxLayout()
+ layout = QtWidgets.QHBoxLayout()
layout.addWidget(self.toolBox)
- self.view = QtGui.QGraphicsView(self.scene)
+ self.view = QtWidgets.QGraphicsView(self.scene)
layout.addWidget(self.view)
- self.widget = QtGui.QWidget()
+ self.widget = QtWidgets.QWidget()
self.widget.setLayout(layout)
self.setCentralWidget(self.widget)
@@ -508,15 +545,15 @@ class MainWindow(QtGui.QMainWindow):
self.underlineAction.setChecked(font.underline())
def about(self):
- QtGui.QMessageBox.about(self, "About Diagram Scene",
+ QtWidgets.QMessageBox.about(self, "About Diagram Scene",
"The <b>Diagram Scene</b> example shows use of the graphics framework.")
def createToolBox(self):
- self.buttonGroup = QtGui.QButtonGroup()
+ self.buttonGroup = QtWidgets.QButtonGroup()
self.buttonGroup.setExclusive(False)
self.buttonGroup.buttonClicked[int].connect(self.buttonGroupClicked)
- layout = QtGui.QGridLayout()
+ layout = QtWidgets.QGridLayout()
layout.addWidget(self.createCellWidget("Conditional", DiagramItem.Conditional),
0, 0)
layout.addWidget(self.createCellWidget("Process", DiagramItem.Step), 0,
@@ -524,31 +561,31 @@ class MainWindow(QtGui.QMainWindow):
layout.addWidget(self.createCellWidget("Input/Output", DiagramItem.Io),
1, 0)
- textButton = QtGui.QToolButton()
+ textButton = QtWidgets.QToolButton()
textButton.setCheckable(True)
self.buttonGroup.addButton(textButton, self.InsertTextButton)
textButton.setIcon(QtGui.QIcon(QtGui.QPixmap(':/images/textpointer.png')
.scaled(30, 30)))
textButton.setIconSize(QtCore.QSize(50, 50))
- textLayout = QtGui.QGridLayout()
+ textLayout = QtWidgets.QGridLayout()
textLayout.addWidget(textButton, 0, 0, QtCore.Qt.AlignHCenter)
- textLayout.addWidget(QtGui.QLabel("Text"), 1, 0,
+ textLayout.addWidget(QtWidgets.QLabel("Text"), 1, 0,
QtCore.Qt.AlignCenter)
- textWidget = QtGui.QWidget()
+ textWidget = QtWidgets.QWidget()
textWidget.setLayout(textLayout)
layout.addWidget(textWidget, 1, 1)
layout.setRowStretch(3, 10)
layout.setColumnStretch(2, 10)
- itemWidget = QtGui.QWidget()
+ itemWidget = QtWidgets.QWidget()
itemWidget.setLayout(layout)
- self.backgroundButtonGroup = QtGui.QButtonGroup()
+ self.backgroundButtonGroup = QtWidgets.QButtonGroup()
self.backgroundButtonGroup.buttonClicked.connect(self.backgroundButtonGroupClicked)
- backgroundLayout = QtGui.QGridLayout()
+ backgroundLayout = QtWidgets.QGridLayout()
backgroundLayout.addWidget(self.createBackgroundCellWidget("Blue Grid",
':/images/background1.png'), 0, 0)
backgroundLayout.addWidget(self.createBackgroundCellWidget("White Grid",
@@ -561,48 +598,48 @@ class MainWindow(QtGui.QMainWindow):
backgroundLayout.setRowStretch(2, 10)
backgroundLayout.setColumnStretch(2, 10)
- backgroundWidget = QtGui.QWidget()
+ backgroundWidget = QtWidgets.QWidget()
backgroundWidget.setLayout(backgroundLayout)
- self.toolBox = QtGui.QToolBox()
- self.toolBox.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Ignored))
+ self.toolBox = QtWidgets.QToolBox()
+ self.toolBox.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Ignored))
self.toolBox.setMinimumWidth(itemWidget.sizeHint().width())
self.toolBox.addItem(itemWidget, "Basic Flowchart Shapes")
self.toolBox.addItem(backgroundWidget, "Backgrounds")
def createActions(self):
- self.toFrontAction = QtGui.QAction(
+ self.toFrontAction = QtWidgets.QAction(
QtGui.QIcon(':/images/bringtofront.png'), "Bring to &Front",
self, shortcut="Ctrl+F", statusTip="Bring item to front",
triggered=self.bringToFront)
- self.sendBackAction = QtGui.QAction(
+ self.sendBackAction = QtWidgets.QAction(
QtGui.QIcon(':/images/sendtoback.png'), "Send to &Back", self,
shortcut="Ctrl+B", statusTip="Send item to back",
triggered=self.sendToBack)
- self.deleteAction = QtGui.QAction(QtGui.QIcon(':/images/delete.png'),
+ self.deleteAction = QtWidgets.QAction(QtGui.QIcon(':/images/delete.png'),
"&Delete", self, shortcut="Delete",
statusTip="Delete item from diagram",
triggered=self.deleteItem)
- self.exitAction = QtGui.QAction("E&xit", self, shortcut="Ctrl+X",
+ self.exitAction = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+X",
statusTip="Quit Scenediagram example", triggered=self.close)
- self.boldAction = QtGui.QAction(QtGui.QIcon(':/images/bold.png'),
+ self.boldAction = QtWidgets.QAction(QtGui.QIcon(':/images/bold.png'),
"Bold", self, checkable=True, shortcut="Ctrl+B",
triggered=self.handleFontChange)
- self.italicAction = QtGui.QAction(QtGui.QIcon(':/images/italic.png'),
+ self.italicAction = QtWidgets.QAction(QtGui.QIcon(':/images/italic.png'),
"Italic", self, checkable=True, shortcut="Ctrl+I",
triggered=self.handleFontChange)
- self.underlineAction = QtGui.QAction(
+ self.underlineAction = QtWidgets.QAction(
QtGui.QIcon(':/images/underline.png'), "Underline", self,
checkable=True, shortcut="Ctrl+U",
triggered=self.handleFontChange)
- self.aboutAction = QtGui.QAction("A&bout", self, shortcut="Ctrl+B",
+ self.aboutAction = QtWidgets.QAction("A&bout", self, shortcut="Ctrl+B",
triggered=self.about)
def createMenus(self):
@@ -624,10 +661,10 @@ class MainWindow(QtGui.QMainWindow):
self.editToolBar.addAction(self.toFrontAction)
self.editToolBar.addAction(self.sendBackAction)
- self.fontCombo = QtGui.QFontComboBox()
+ self.fontCombo = QtWidgets.QFontComboBox()
self.fontCombo.currentFontChanged.connect(self.currentFontChanged)
- self.fontSizeCombo = QtGui.QComboBox()
+ self.fontSizeCombo = QtWidgets.QComboBox()
self.fontSizeCombo.setEditable(True)
for i in range(8, 30, 2):
self.fontSizeCombo.addItem(str(i))
@@ -635,8 +672,8 @@ class MainWindow(QtGui.QMainWindow):
self.fontSizeCombo.setValidator(validator)
self.fontSizeCombo.currentIndexChanged.connect(self.fontSizeChanged)
- self.fontColorToolButton = QtGui.QToolButton()
- self.fontColorToolButton.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
+ self.fontColorToolButton = QtWidgets.QToolButton()
+ self.fontColorToolButton.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup)
self.fontColorToolButton.setMenu(
self.createColorMenu(self.textColorChanged, QtCore.Qt.black))
self.textAction = self.fontColorToolButton.menu().defaultAction()
@@ -646,8 +683,8 @@ class MainWindow(QtGui.QMainWindow):
self.fontColorToolButton.setAutoFillBackground(True)
self.fontColorToolButton.clicked.connect(self.textButtonTriggered)
- self.fillColorToolButton = QtGui.QToolButton()
- self.fillColorToolButton.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
+ self.fillColorToolButton = QtWidgets.QToolButton()
+ self.fillColorToolButton.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup)
self.fillColorToolButton.setMenu(
self.createColorMenu(self.itemColorChanged, QtCore.Qt.white))
self.fillAction = self.fillColorToolButton.menu().defaultAction()
@@ -656,8 +693,8 @@ class MainWindow(QtGui.QMainWindow):
QtCore.Qt.white))
self.fillColorToolButton.clicked.connect(self.fillButtonTriggered)
- self.lineColorToolButton = QtGui.QToolButton()
- self.lineColorToolButton.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
+ self.lineColorToolButton = QtWidgets.QToolButton()
+ self.lineColorToolButton.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup)
self.lineColorToolButton.setMenu(
self.createColorMenu(self.lineColorChanged, QtCore.Qt.black))
self.lineAction = self.lineColorToolButton.menu().defaultAction()
@@ -678,21 +715,21 @@ class MainWindow(QtGui.QMainWindow):
self.colorToolBar.addWidget(self.fillColorToolButton)
self.colorToolBar.addWidget(self.lineColorToolButton)
- pointerButton = QtGui.QToolButton()
+ pointerButton = QtWidgets.QToolButton()
pointerButton.setCheckable(True)
pointerButton.setChecked(True)
pointerButton.setIcon(QtGui.QIcon(':/images/pointer.png'))
- linePointerButton = QtGui.QToolButton()
+ linePointerButton = QtWidgets.QToolButton()
linePointerButton.setCheckable(True)
linePointerButton.setIcon(QtGui.QIcon(':/images/linepointer.png'))
- self.pointerTypeGroup = QtGui.QButtonGroup()
+ self.pointerTypeGroup = QtWidgets.QButtonGroup()
self.pointerTypeGroup.addButton(pointerButton, DiagramScene.MoveItem)
self.pointerTypeGroup.addButton(linePointerButton,
DiagramScene.InsertLine)
self.pointerTypeGroup.buttonClicked[int].connect(self.pointerGroupClicked)
- self.sceneScaleCombo = QtGui.QComboBox()
+ self.sceneScaleCombo = QtWidgets.QComboBox()
self.sceneScaleCombo.addItems(["50%", "75%", "100%", "125%", "150%"])
self.sceneScaleCombo.setCurrentIndex(2)
self.sceneScaleCombo.currentIndexChanged[str].connect(self.sceneScaleChanged)
@@ -703,18 +740,18 @@ class MainWindow(QtGui.QMainWindow):
self.pointerToolbar.addWidget(self.sceneScaleCombo)
def createBackgroundCellWidget(self, text, image):
- button = QtGui.QToolButton()
+ button = QtWidgets.QToolButton()
button.setText(text)
button.setIcon(QtGui.QIcon(image))
button.setIconSize(QtCore.QSize(50, 50))
button.setCheckable(True)
self.backgroundButtonGroup.addButton(button)
- layout = QtGui.QGridLayout()
+ layout = QtWidgets.QGridLayout()
layout.addWidget(button, 0, 0, QtCore.Qt.AlignHCenter)
- layout.addWidget(QtGui.QLabel(text), 1, 0, QtCore.Qt.AlignCenter)
+ layout.addWidget(QtWidgets.QLabel(text), 1, 0, QtCore.Qt.AlignCenter)
- widget = QtGui.QWidget()
+ widget = QtWidgets.QWidget()
widget.setLayout(layout)
return widget
@@ -723,17 +760,17 @@ class MainWindow(QtGui.QMainWindow):
item = DiagramItem(diagramType, self.itemMenu)
icon = QtGui.QIcon(item.image())
- button = QtGui.QToolButton()
+ button = QtWidgets.QToolButton()
button.setIcon(icon)
button.setIconSize(QtCore.QSize(50, 50))
button.setCheckable(True)
self.buttonGroup.addButton(button, diagramType)
- layout = QtGui.QGridLayout()
+ layout = QtWidgets.QGridLayout()
layout.addWidget(button, 0, 0, QtCore.Qt.AlignHCenter)
- layout.addWidget(QtGui.QLabel(text), 1, 0, QtCore.Qt.AlignCenter)
+ layout.addWidget(QtWidgets.QLabel(text), 1, 0, QtCore.Qt.AlignCenter)
- widget = QtGui.QWidget()
+ widget = QtWidgets.QWidget()
widget.setLayout(layout)
return widget
@@ -742,9 +779,9 @@ class MainWindow(QtGui.QMainWindow):
colors = [QtCore.Qt.black, QtCore.Qt.white, QtCore.Qt.red, QtCore.Qt.blue, QtCore.Qt.yellow]
names = ["black", "white", "red", "blue", "yellow"]
- colorMenu = QtGui.QMenu(self)
+ colorMenu = QtWidgets.QMenu(self)
for color, name in zip(colors, names):
- action = QtGui.QAction(self.createColorIcon(color), name, self,
+ action = QtWidgets.QAction(self.createColorIcon(color), name, self,
triggered=slot)
action.setData(QtGui.QColor(color))
colorMenu.addAction(action)
@@ -779,7 +816,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.setGeometry(100, 100, 800, 500)
diff --git a/examples/graphicsview/dragdroprobot/dragdroprobot.py b/examples/graphicsview/dragdroprobot/dragdroprobot.py
index 080ce70..ae231b6 100755
--- a/examples/graphicsview/dragdroprobot/dragdroprobot.py
+++ b/examples/graphicsview/dragdroprobot/dragdroprobot.py
@@ -1,32 +1,52 @@
#!/usr/bin/env python
-############################################################################
+#############################################################################
##
-## Copyright (C) 2006-2006 Trolltech ASA. All rights reserved.
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
##
-## Licensees holding a valid Qt License Agreement may use this file in
-## accordance with the rights, responsibilities and obligations
-## contained therein. Please consult your licensing agreement or
-## contact sales@trolltech.com if any conditions of this licensing
-## agreement are not clear to you.
+## $QT_BEGIN_LICENSE:BSD$
+## You may use this file under the terms of the BSD license as follows:
##
-## Further information about Qt licensing is available at:
-## http://www.trolltech.com/products/qt/licensing.html or by
-## contacting info@trolltech.com.
+## "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 file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
##
-############################################################################
+## 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 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
import dragdroprobot_rc
-class ColorItem(QtGui.QGraphicsItem):
+class ColorItem(QtWidgets.QGraphicsItem):
n = 0
def __init__(self):
@@ -60,7 +80,7 @@ class ColorItem(QtGui.QGraphicsItem):
self.setCursor(QtCore.Qt.ClosedHandCursor)
def mouseMoveEvent(self, event):
- if QtCore.QLineF(QtCore.QPointF(event.screenPos()), QtCore.QPointF(event.buttonDownScreenPos(QtCore.Qt.LeftButton))).length() < QtGui.QApplication.startDragDistance():
+ if QtCore.QLineF(QtCore.QPointF(event.screenPos()), QtCore.QPointF(event.buttonDownScreenPos(QtCore.Qt.LeftButton))).length() < QtWidgets.QApplication.startDragDistance():
return
drag = QtGui.QDrag(event.widget())
@@ -98,7 +118,7 @@ class ColorItem(QtGui.QGraphicsItem):
self.setCursor(QtCore.Qt.OpenHandCursor)
-class RobotPart(QtGui.QGraphicsItem):
+class RobotPart(QtWidgets.QGraphicsItem):
def __init__(self, parent=None):
super(RobotPart, self).__init__(parent)
@@ -214,7 +234,7 @@ class Robot(RobotPart):
self.animations = []
for item, pos_x, pos_y, rotation1, rotation2 in settings:
item.setPos(pos_x,pos_y)
- animation = QtGui.QGraphicsItemAnimation()
+ animation = QtWidgets.QGraphicsItemAnimation()
animation.setItem(item)
animation.setTimeLine(self.timeline)
animation.setRotationAt(0, rotation1)
@@ -240,11 +260,11 @@ if __name__== '__main__':
import sys
import math
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
QtCore.qsrand(QtCore.QTime(0, 0, 0).secsTo(QtCore.QTime.currentTime()))
- scene = QtGui.QGraphicsScene(-200, -200, 400, 400)
+ scene = QtWidgets.QGraphicsScene(-200, -200, 400, 400)
for i in range(10):
item = ColorItem()
@@ -253,13 +273,13 @@ if __name__== '__main__':
scene.addItem(item)
robot = Robot()
- robot.scale(1.2, 1.2)
+ robot.setTransform(QtGui.QTransform().scale(1.2, 1.2))
robot.setPos(0, -20)
scene.addItem(robot)
- view = QtGui.QGraphicsView(scene)
+ view = QtWidgets.QGraphicsView(scene)
view.setRenderHint(QtGui.QPainter.Antialiasing)
- view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)
+ view.setViewportUpdateMode(QtWidgets.QGraphicsView.BoundingRectViewportUpdate)
view.setBackgroundBrush(QtGui.QColor(230, 200, 167))
view.setWindowTitle("Drag and Drop Robot")
view.show()
diff --git a/examples/graphicsview/elasticnodes.py b/examples/graphicsview/elasticnodes.py
index bd29b7a..9e37656 100755
--- a/examples/graphicsview/elasticnodes.py
+++ b/examples/graphicsview/elasticnodes.py
@@ -2,39 +2,59 @@
#############################################################################
##
-## Copyright (C) 2006-2006 Trolltech ASA. All rights reserved.
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
##
-## Licensees holding a valid Qt License Agreement may use this file in
-## accordance with the rights, responsibilities and obligations
-## contained therein. Please consult your licensing agreement or
-## contact sales@trolltech.com if any conditions of this licensing
-## agreement are not clear to you.
+## $QT_BEGIN_LICENSE:BSD$
+## You may use this file under the terms of the BSD license as follows:
##
-## Further information about Qt licensing is available at:
-## http://www.trolltech.com/products/qt/licensing.html or by
-## contacting info@trolltech.com.
+## "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 file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+##
+## 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 sys
import weakref
import math
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class Edge(QtGui.QGraphicsItem):
+class Edge(QtWidgets.QGraphicsItem):
Pi = math.pi
TwoPi = 2.0 * Pi
- Type = QtGui.QGraphicsItem.UserType + 2
+ Type = QtWidgets.QGraphicsItem.UserType + 2
def __init__(self, sourceNode, destNode):
- QtGui.QGraphicsItem.__init__(self)
+ QtWidgets.QGraphicsItem.__init__(self)
self.arrowSize = 10.0
self.sourcePoint = QtCore.QPointF()
@@ -122,17 +142,17 @@ class Edge(QtGui.QGraphicsItem):
painter.drawPolygon(QtGui.QPolygonF([line.p2(), destArrowP1, destArrowP2]))
-class Node(QtGui.QGraphicsItem):
- Type = QtGui.QGraphicsItem.UserType + 1
+class Node(QtWidgets.QGraphicsItem):
+ Type = QtWidgets.QGraphicsItem.UserType + 1
def __init__(self, graphWidget):
- QtGui.QGraphicsItem.__init__(self)
+ QtWidgets.QGraphicsItem.__init__(self)
self.graph = weakref.ref(graphWidget)
self.edgeList = []
self.newPos = QtCore.QPointF()
- self.setFlag(QtGui.QGraphicsItem.ItemIsMovable)
- self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges)
+ self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable)
+ self.setFlag(QtWidgets.QGraphicsItem.ItemSendsGeometryChanges)
self.setCacheMode(self.DeviceCoordinateCache)
self.setZValue(-1)
@@ -207,7 +227,7 @@ class Node(QtGui.QGraphicsItem):
painter.drawEllipse(-7, -7, 20, 20)
gradient = QtGui.QRadialGradient(-3, -3, 10)
- if option.state & QtGui.QStyle.State_Sunken:
+ if option.state & QtWidgets.QStyle.State_Sunken:
gradient.setCenter(3, 3)
gradient.setFocalPoint(3, 3)
gradient.setColorAt(1, QtGui.QColor(QtCore.Qt.yellow).lighter(120))
@@ -221,36 +241,36 @@ class Node(QtGui.QGraphicsItem):
painter.drawEllipse(-10, -10, 20, 20)
def itemChange(self, change, value):
- if change == QtGui.QGraphicsItem.ItemPositionChange:
+ if change == QtWidgets.QGraphicsItem.ItemPositionChange:
for edge in self.edgeList:
edge().adjust()
self.graph().itemMoved()
- return QtGui.QGraphicsItem.itemChange(self, change, value)
+ return QtWidgets.QGraphicsItem.itemChange(self, change, value)
def mousePressEvent(self, event):
self.update()
- QtGui.QGraphicsItem.mousePressEvent(self, event)
+ QtWidgets.QGraphicsItem.mousePressEvent(self, event)
def mouseReleaseEvent(self, event):
self.update()
- QtGui.QGraphicsItem.mouseReleaseEvent(self, event)
+ QtWidgets.QGraphicsItem.mouseReleaseEvent(self, event)
-class GraphWidget(QtGui.QGraphicsView):
+class GraphWidget(QtWidgets.QGraphicsView):
def __init__(self):
- QtGui.QGraphicsView.__init__(self)
+ QtWidgets.QGraphicsView.__init__(self)
self.timerId = 0
- scene = QtGui.QGraphicsScene(self)
- scene.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex)
+ scene = QtWidgets.QGraphicsScene(self)
+ scene.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex)
scene.setSceneRect(-200, -200, 400, 400)
self.setScene(scene)
- self.setCacheMode(QtGui.QGraphicsView.CacheBackground)
+ self.setCacheMode(QtWidgets.QGraphicsView.CacheBackground)
self.setRenderHint(QtGui.QPainter.Antialiasing)
- self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
- self.setResizeAnchor(QtGui.QGraphicsView.AnchorViewCenter)
+ self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse)
+ self.setResizeAnchor(QtWidgets.QGraphicsView.AnchorViewCenter)
node1 = Node(self)
node2 = Node(self)
@@ -321,7 +341,7 @@ class GraphWidget(QtGui.QGraphicsView):
if isinstance(item, Node):
item.setPos(-150 + QtCore.qrand() % 300, -150 + QtCore.qrand() % 300)
else:
- QtGui.QGraphicsView.keyPressEvent(self, event)
+ QtWidgets.QGraphicsView.keyPressEvent(self, event)
def timerEvent(self, event):
@@ -356,7 +376,7 @@ class GraphWidget(QtGui.QGraphicsView):
gradient = QtGui.QLinearGradient(sceneRect.topLeft(), sceneRect.bottomRight())
gradient.setColorAt(0, QtCore.Qt.white)
gradient.setColorAt(1, QtCore.Qt.lightGray)
- painter.fillRect(rect.intersect(sceneRect), QtGui.QBrush(gradient))
+ painter.fillRect(rect.intersected(sceneRect), QtGui.QBrush(gradient))
painter.setBrush(QtCore.Qt.NoBrush)
painter.drawRect(sceneRect)
@@ -385,7 +405,7 @@ class GraphWidget(QtGui.QGraphicsView):
if __name__ == "__main__":
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
QtCore.qsrand(QtCore.QTime(0,0,0).secsTo(QtCore.QTime.currentTime()))
widget = GraphWidget()
diff --git a/examples/itemviews/addressbook/adddialogwidget.py b/examples/itemviews/addressbook/adddialogwidget.py
index da088b8..55ce90b 100644
--- a/examples/itemviews/addressbook/adddialogwidget.py
+++ b/examples/itemviews/addressbook/adddialogwidget.py
@@ -1,50 +1,49 @@
#!/usr/bin/python
-"""**************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** 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 Nokia Corporation and its Subsidiary(-ies) 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."
-**
-*****************************************************************************
-** February 2011
-** - addressbook example ported to PySide by Arun Srinivasan
-** <rulfzid@gmail.com>
-**************************************************************************"""
-
-from PySide.QtCore import Qt
-from PySide.QtGui import (QDialog, QLabel, QTextEdit, QLineEdit,
- QDialogButtonBox, QGridLayout, QVBoxLayout)
+#############################################################################
+##
+## Copyright (C) 2011 Arun Srinivasan <rulfzid@gmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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.QtCore import Qt
+from PySide2.QtWidgets import (QDialog, QLabel, QTextEdit, QLineEdit,
+ QDialogButtonBox, QGridLayout, QVBoxLayout)
class AddDialogWidget(QDialog):
""" A dialog to add a new address to the addressbook. """
@@ -92,7 +91,7 @@ class AddDialogWidget(QDialog):
if __name__ == "__main__":
import sys
- from PySide.QtGui import QApplication
+ from PySide2.QtWidgets import QApplication
app = QApplication(sys.argv)
diff --git a/examples/itemviews/addressbook/addressbook.py b/examples/itemviews/addressbook/addressbook.py
index a3fec1d..4e68d27 100755
--- a/examples/itemviews/addressbook/addressbook.py
+++ b/examples/itemviews/addressbook/addressbook.py
@@ -1,48 +1,47 @@
#!/usr/bin/python
-"""**************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** 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 Nokia Corporation and its Subsidiary(-ies) 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."
-**
-*****************************************************************************
-** February 2011
-** - addressbook example ported to PySide by Arun Srinivasan
-** <rulfzid@gmail.com>
-**************************************************************************"""
-
-from PySide.QtGui import (QMainWindow, QAction, QFileDialog, QApplication)
+#############################################################################
+##
+## Copyright (C) 2011 Arun Srinivasan <rulfzid@gmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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.QtWidgets import (QMainWindow, QAction, QFileDialog, QApplication)
from addresswidget import AddressWidget
@@ -94,13 +93,10 @@ class MainWindow(QMainWindow):
# Quick gotcha:
#
# QFiledialog.getOpenFilename and QFileDialog.get.SaveFileName don't
- # behave in PySide as they do in QT, where they return a QString
+ # behave in PySide2 as they do in Qt, where they return a QString
# containing the filename.
#
- # In PySide (and, I believe, PyQT), these functions return a tuple:
- # (filename, filter)
- #
- # http://www.pyside.org/docs/pyside/PySide/QtGui/QFileDialog.html
+ # In PySide2, these functions return a tuple: (filename, filter)
def openFile(self):
filename, _ = QFileDialog.getOpenFileName(self)
diff --git a/examples/itemviews/addressbook/addresswidget.py b/examples/itemviews/addressbook/addresswidget.py
index 76cec4a..675c0b6 100644
--- a/examples/itemviews/addressbook/addresswidget.py
+++ b/examples/itemviews/addressbook/addresswidget.py
@@ -1,56 +1,55 @@
#!/usr/bin/python
-"""**************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** 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 Nokia Corporation and its Subsidiary(-ies) 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."
-**
-*****************************************************************************
-** February 2011
-** - addressbook example ported to PySide by Arun Srinivasan
-** <rulfzid@gmail.com>
-**************************************************************************"""
+#############################################################################
+##
+## Copyright (C) 2011 Arun Srinivasan <rulfzid@gmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
try:
import cpickle as pickle
except ImportError:
import pickle
-from PySide.QtCore import (Qt, Signal, QRegExp, QModelIndex)
-from PySide.QtGui import (QWidget, QTabWidget, QItemSelectionModel,
- QMessageBox, QTableView, QSortFilterProxyModel,
- QAbstractItemView, QItemSelection)
+from PySide2.QtCore import (Qt, Signal, QRegExp, QModelIndex,
+ QItemSelection, QItemSelectionModel, QSortFilterProxyModel)
+from PySide2.QtWidgets import (QWidget, QTabWidget, QMessageBox, QTableView,
+ QAbstractItemView)
from tablemodel import TableModel
from newaddresstab import NewAddressTab
@@ -242,7 +241,7 @@ class AddressWidget(QTabWidget):
if __name__ == "__main__":
import sys
- from PySide.QtGui import QApplication
+ from PySide2.QtWidgets import QApplication
app = QApplication(sys.argv)
addressWidget = AddressWidget()
diff --git a/examples/itemviews/addressbook/newaddresstab.py b/examples/itemviews/addressbook/newaddresstab.py
index 2b46fd7..93ccff6 100644
--- a/examples/itemviews/addressbook/newaddresstab.py
+++ b/examples/itemviews/addressbook/newaddresstab.py
@@ -1,49 +1,48 @@
#!/usr/bin/python
-"""**************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** 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 Nokia Corporation and its Subsidiary(-ies) 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."
-**
-*****************************************************************************
-** February 2011
-** - addressbook example ported to PySide by Arun Srinivasan
-** <rulfzid@gmail.com>
-**************************************************************************"""
-
-from PySide.QtCore import (Qt, Signal)
-from PySide.QtGui import (QWidget, QLabel, QPushButton, QVBoxLayout)
+#############################################################################
+##
+## Copyright (C) 2011 Arun Srinivasan <rulfzid@gmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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.QtCore import (Qt, Signal)
+from PySide2.QtWidgets import (QWidget, QLabel, QPushButton, QVBoxLayout)
from adddialogwidget import AddDialogWidget
@@ -86,7 +85,7 @@ if __name__ == "__main__":
print("Address:" + address)
import sys
- from PySide.QtGui import QApplication
+ from PySide2.QtWidgets import QApplication
app = QApplication(sys.argv)
newAddressTab = NewAddressTab()
diff --git a/examples/itemviews/addressbook/tablemodel.py b/examples/itemviews/addressbook/tablemodel.py
index 98b3a02..9055999 100644
--- a/examples/itemviews/addressbook/tablemodel.py
+++ b/examples/itemviews/addressbook/tablemodel.py
@@ -1,48 +1,47 @@
#!/usr/bin/python
-"""**************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** 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 Nokia Corporation and its Subsidiary(-ies) 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."
-**
-*****************************************************************************
-** February 2011
-** - addressbook example ported to PySide by Arun Srinivasan
-** <rulfzid@gmail.com>
-**************************************************************************"""
-
-from PySide.QtCore import (Qt, QAbstractTableModel, QModelIndex)
+#############################################################################
+##
+## Copyright (C) 2011 Arun Srinivasan <rulfzid@gmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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.QtCore import (Qt, QAbstractTableModel, QModelIndex)
class TableModel(QAbstractTableModel):
@@ -132,7 +131,7 @@ class TableModel(QAbstractTableModel):
else:
return False
- self.dataChanged.emit(index, index)
+ self.dataChanged.emit(index, index, 0)
return True
return False
diff --git a/examples/itemviews/basicsortfiltermodel.py b/examples/itemviews/basicsortfiltermodel.py
index 79e33bb..4308f42 100755
--- a/examples/itemviews/basicsortfiltermodel.py
+++ b/examples/itemviews/basicsortfiltermodel.py
@@ -1,71 +1,91 @@
#!/usr/bin/env python
-############################################################################
+#############################################################################
##
-## Copyright (C) 2006-2007 Trolltech ASA. All rights reserved.
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
##
-## Licensees holding a valid Qt License Agreement may use this file in
-## accordance with the rights, responsibilities and obligations
-## contained therein. Please consult your licensing agreement or
-## contact sales@trolltech.com if any conditions of this licensing
-## agreement are not clear to you.
+## $QT_BEGIN_LICENSE:BSD$
+## You may use this file under the terms of the BSD license as follows:
+##g
+## "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.
##
-## Further information about Qt licensing is available at:
-## http://www.trolltech.com/products/qt/licensing.html or by
-## contacting info@trolltech.com.
##
-## This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+## 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 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class Window(QtGui.QWidget):
+class Window(QtWidgets.QWidget):
def __init__(self):
super(Window, self).__init__()
- self.proxyModel = QtGui.QSortFilterProxyModel()
+ self.proxyModel = QtCore.QSortFilterProxyModel()
self.proxyModel.setDynamicSortFilter(True)
- self.sourceGroupBox = QtGui.QGroupBox("Original Model")
- self.proxyGroupBox = QtGui.QGroupBox("Sorted/Filtered Model")
+ self.sourceGroupBox = QtWidgets.QGroupBox("Original Model")
+ self.proxyGroupBox = QtWidgets.QGroupBox("Sorted/Filtered Model")
- self.sourceView = QtGui.QTreeView()
+ self.sourceView = QtWidgets.QTreeView()
self.sourceView.setRootIsDecorated(False)
self.sourceView.setAlternatingRowColors(True)
- self.proxyView = QtGui.QTreeView()
+ self.proxyView = QtWidgets.QTreeView()
self.proxyView.setRootIsDecorated(False)
self.proxyView.setAlternatingRowColors(True)
self.proxyView.setModel(self.proxyModel)
self.proxyView.setSortingEnabled(True)
- self.sortCaseSensitivityCheckBox = QtGui.QCheckBox("Case sensitive sorting")
- self.filterCaseSensitivityCheckBox = QtGui.QCheckBox("Case sensitive filter")
+ self.sortCaseSensitivityCheckBox = QtWidgets.QCheckBox("Case sensitive sorting")
+ self.filterCaseSensitivityCheckBox = QtWidgets.QCheckBox("Case sensitive filter")
- self.filterPatternLineEdit = QtGui.QLineEdit()
- self.filterPatternLabel = QtGui.QLabel("&Filter pattern:")
+ self.filterPatternLineEdit = QtWidgets.QLineEdit()
+ self.filterPatternLabel = QtWidgets.QLabel("&Filter pattern:")
self.filterPatternLabel.setBuddy(self.filterPatternLineEdit)
- self.filterSyntaxComboBox = QtGui.QComboBox()
+ self.filterSyntaxComboBox = QtWidgets.QComboBox()
self.filterSyntaxComboBox.addItem("Regular expression",
QtCore.QRegExp.RegExp)
self.filterSyntaxComboBox.addItem("Wildcard",
QtCore.QRegExp.Wildcard)
self.filterSyntaxComboBox.addItem("Fixed string",
QtCore.QRegExp.FixedString)
- self.filterSyntaxLabel = QtGui.QLabel("Filter &syntax:")
+ self.filterSyntaxLabel = QtWidgets.QLabel("Filter &syntax:")
self.filterSyntaxLabel.setBuddy(self.filterSyntaxComboBox)
- self.filterColumnComboBox = QtGui.QComboBox()
+ self.filterColumnComboBox = QtWidgets.QComboBox()
self.filterColumnComboBox.addItem("Subject")
self.filterColumnComboBox.addItem("Sender")
self.filterColumnComboBox.addItem("Date")
- self.filterColumnLabel = QtGui.QLabel("Filter &column:")
+ self.filterColumnLabel = QtWidgets.QLabel("Filter &column:")
self.filterColumnLabel.setBuddy(self.filterColumnComboBox)
self.filterPatternLineEdit.textChanged.connect(self.filterRegExpChanged)
@@ -74,11 +94,11 @@ class Window(QtGui.QWidget):
self.filterCaseSensitivityCheckBox.toggled.connect(self.filterRegExpChanged)
self.sortCaseSensitivityCheckBox.toggled.connect(self.sortChanged)
- sourceLayout = QtGui.QHBoxLayout()
+ sourceLayout = QtWidgets.QHBoxLayout()
sourceLayout.addWidget(self.sourceView)
self.sourceGroupBox.setLayout(sourceLayout)
- proxyLayout = QtGui.QGridLayout()
+ proxyLayout = QtWidgets.QGridLayout()
proxyLayout.addWidget(self.proxyView, 0, 0, 1, 3)
proxyLayout.addWidget(self.filterPatternLabel, 1, 0)
proxyLayout.addWidget(self.filterPatternLineEdit, 1, 1, 1, 2)
@@ -90,7 +110,7 @@ class Window(QtGui.QWidget):
proxyLayout.addWidget(self.sortCaseSensitivityCheckBox, 4, 2)
self.proxyGroupBox.setLayout(proxyLayout)
- mainLayout = QtGui.QVBoxLayout()
+ mainLayout = QtWidgets.QVBoxLayout()
mainLayout.addWidget(self.sourceGroupBox)
mainLayout.addWidget(self.proxyGroupBox)
self.setLayout(mainLayout)
@@ -176,7 +196,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
window = Window()
window.setSourceModel(createMailModel(window))
window.show()
diff --git a/examples/itemviews/fetchmore.py b/examples/itemviews/fetchmore.py
index 4e9f13a..f24f51d 100755
--- a/examples/itemviews/fetchmore.py
+++ b/examples/itemviews/fetchmore.py
@@ -1,9 +1,48 @@
#!/usr/bin/python
-# Fetch More Example
-# Ported to PyQt4 by Darryl Wallace, 2009 - wallacdj@gmail.com
-
-from PySide2 import QtCore, QtGui
+#############################################################################
+##
+## Copyright (C) 2009 Darryl Wallace, 2009 <wallacdj@gmail.com>
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## You may use this file under the terms of the BSD license as follows:
+##g
+## "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 import QtCore, QtGui, QtWidgets
class FileListModel(QtCore.QAbstractListModel):
@@ -30,10 +69,11 @@ class FileListModel(QtCore.QAbstractListModel):
if role == QtCore.Qt.BackgroundRole:
batch = (index.row() // 100) % 2
+# FIXME: QGuiApplication::palette() required
if batch == 0:
- return QtGui.qApp.palette().base()
+ return QtWidgets.qApp.palette().base()
- return QtGui.qApp.palette().alternateBase()
+ return QtWidgets.qApp.palette().alternateBase()
return None
@@ -56,33 +96,34 @@ class FileListModel(QtCore.QAbstractListModel):
def setDirPath(self, path):
dir = QtCore.QDir(path)
+ self.beginResetModel()
self.fileList = list(dir.entryList())
self.fileCount = 0
- self.reset()
+ self.endResetModel()
-class Window(QtGui.QWidget):
+class Window(QtWidgets.QWidget):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
model = FileListModel(self)
model.setDirPath(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.PrefixPath))
- label = QtGui.QLabel("Directory")
- lineEdit = QtGui.QLineEdit()
+ label = QtWidgets.QLabel("Directory")
+ lineEdit = QtWidgets.QLineEdit()
label.setBuddy(lineEdit)
- view = QtGui.QListView()
+ view = QtWidgets.QListView()
view.setModel(model)
- self.logViewer = QtGui.QTextBrowser()
- self.logViewer.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred))
+ self.logViewer = QtWidgets.QTextBrowser()
+ self.logViewer.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred))
lineEdit.textChanged.connect(model.setDirPath)
lineEdit.textChanged.connect(self.logViewer.clear)
model.numberPopulated.connect(self.updateLog)
- layout = QtGui.QGridLayout()
+ layout = QtWidgets.QGridLayout()
layout.addWidget(label, 0, 0)
layout.addWidget(lineEdit, 0, 1)
layout.addWidget(view, 1, 0, 1, 2)
@@ -99,7 +140,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
window = Window()
window.show()
diff --git a/examples/itemviews/stardelegate/stardelegate.py b/examples/itemviews/stardelegate/stardelegate.py
index a0390fa..abcf8b3 100755
--- a/examples/itemviews/stardelegate/stardelegate.py
+++ b/examples/itemviews/stardelegate/stardelegate.py
@@ -1,48 +1,48 @@
#!/usr/bin/python
-"""**************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** 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 Nokia Corporation and its Subsidiary(-ies) 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."
-**
-*****************************************************************************
-** February 2011
-** - stardelegate example ported to PySide by Arun Srinivasan
-** <rulfzid@gmail.com>
-**************************************************************************"""
-
-from PySide.QtGui import (QItemDelegate, QStyledItemDelegate, QStyle)
+#############################################################################
+##
+## Copyright (C) 2010 Hans-Peter Jansen <hpj@urpla.net>
+## Copyright (C) 2011 Arun Srinivasan <rulfzid@gmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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.QtWidgets import (QItemDelegate, QStyledItemDelegate, QStyle)
from starrating import StarRating
from stareditor import StarEditor
@@ -135,13 +135,13 @@ class StarDelegate(QStyledItemDelegate):
# The commitData signal must be emitted when we've finished editing
# and need to write our changed back to the model.
self.commitData.emit(editor)
- self.closeEditor.emit(editor)
+ self.closeEditor.emit(editor, QStyledItemDelegate.NoHint)
if __name__ == "__main__":
""" Run the application. """
- from PySide.QtGui import (QApplication, QTableWidget, QTableWidgetItem,
- QAbstractItemView)
+ from PySide2.QtWidgets import (QApplication, QTableWidget, QTableWidgetItem,
+ QAbstractItemView)
import sys
app = QApplication(sys.argv)
@@ -172,4 +172,3 @@ if __name__ == "__main__":
tableWidget.show()
sys.exit(app.exec_())
- \ No newline at end of file
diff --git a/examples/itemviews/stardelegate/stareditor.py b/examples/itemviews/stardelegate/stareditor.py
index 63a0d56..5cbd585 100644
--- a/examples/itemviews/stardelegate/stareditor.py
+++ b/examples/itemviews/stardelegate/stareditor.py
@@ -1,49 +1,50 @@
#!/usr/bin/python
-"""**************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** 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 Nokia Corporation and its Subsidiary(-ies) 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."
-**
-*****************************************************************************
-** February 2011
-** - stardelegate example ported to PySide by Arun Srinivasan
-** <rulfzid@gmail.com>
-**************************************************************************"""
+#############################################################################
+##
+## Copyright (C) 2010 Hans-Peter Jansen <hpj@urpla.net>
+## Copyright (C) 2011 Arun Srinivasan <rulfzid@gmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 PySide.QtGui import (QWidget, QPainter)
-from PySide.QtCore import Signal
+from PySide2.QtWidgets import (QWidget)
+from PySide2.QtGui import (QPainter)
+from PySide2.QtCore import Signal
class StarEditor(QWidget):
diff --git a/examples/itemviews/stardelegate/starrating.py b/examples/itemviews/stardelegate/starrating.py
index bad120f..e90bc35 100644
--- a/examples/itemviews/stardelegate/starrating.py
+++ b/examples/itemviews/stardelegate/starrating.py
@@ -1,51 +1,51 @@
#!/usr/bin/python
-"""**************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** 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 Nokia Corporation and its Subsidiary(-ies) 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."
-**
-*****************************************************************************
-** February 2011
-** - stardelegate example ported to PySide by Arun Srinivasan
-** <rulfzid@gmail.com>
-**************************************************************************"""
+#############################################################################
+##
+## Copyright (C) 2010 Hans-Peter Jansen <hpj@urpla.net>
+## Copyright (C) 2011 Arun Srinivasan <rulfzid@gmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 math import (cos, sin, pi)
-from PySide.QtGui import (QPainter, QPolygonF)
-from PySide.QtCore import (QPointF, QSize, Qt)
+from PySide2.QtGui import (QPainter, QPolygonF)
+from PySide2.QtCore import (QPointF, QSize, Qt)
PAINTING_SCALE_FACTOR = 20
@@ -99,4 +99,4 @@ class StarRating(object):
painter.drawPolygon(self.diamondPolygon, Qt.WindingFill)
painter.translate(1.0, 0.0)
- painter.restore() \ No newline at end of file
+ painter.restore()
diff --git a/examples/layouts/basiclayouts.py b/examples/layouts/basiclayouts.py
index eedc3fe..03f3315 100755
--- a/examples/layouts/basiclayouts.py
+++ b/examples/layouts/basiclayouts.py
@@ -1,11 +1,52 @@
#!/usr/bin/env python
-"""PyQt4 port of the layouts/basiclayout example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui
-
-
-class Dialog(QtGui.QDialog):
+############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/layouts/basiclayout example from Qt v5.x"""
+
+from PySide2 import QtCore, QtGui, QtWidgets
+
+
+class Dialog(QtWidgets.QDialog):
NumGridRows = 3
NumButtons = 4
@@ -17,16 +58,16 @@ class Dialog(QtGui.QDialog):
self.createGridGroupBox()
self.createFormGroupBox()
- bigEditor = QtGui.QTextEdit()
+ bigEditor = QtWidgets.QTextEdit()
bigEditor.setPlainText("This widget takes up all the remaining space "
"in the top-level layout.")
- buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
+ buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
buttonBox.accepted.connect(self.accept)
buttonBox.rejected.connect(self.reject)
- mainLayout = QtGui.QVBoxLayout()
+ mainLayout = QtWidgets.QVBoxLayout()
mainLayout.setMenuBar(self.menuBar)
mainLayout.addWidget(self.horizontalGroupBox)
mainLayout.addWidget(self.gridGroupBox)
@@ -38,35 +79,35 @@ class Dialog(QtGui.QDialog):
self.setWindowTitle("Basic Layouts")
def createMenu(self):
- self.menuBar = QtGui.QMenuBar()
+ self.menuBar = QtWidgets.QMenuBar()
- self.fileMenu = QtGui.QMenu("&File", self)
+ self.fileMenu = QtWidgets.QMenu("&File", self)
self.exitAction = self.fileMenu.addAction("E&xit")
self.menuBar.addMenu(self.fileMenu)
self.exitAction.triggered.connect(self.accept)
def createHorizontalGroupBox(self):
- self.horizontalGroupBox = QtGui.QGroupBox("Horizontal layout")
- layout = QtGui.QHBoxLayout()
+ self.horizontalGroupBox = QtWidgets.QGroupBox("Horizontal layout")
+ layout = QtWidgets.QHBoxLayout()
for i in range(Dialog.NumButtons):
- button = QtGui.QPushButton("Button %d" % (i + 1))
+ button = QtWidgets.QPushButton("Button %d" % (i + 1))
layout.addWidget(button)
self.horizontalGroupBox.setLayout(layout)
def createGridGroupBox(self):
- self.gridGroupBox = QtGui.QGroupBox("Grid layout")
- layout = QtGui.QGridLayout()
+ self.gridGroupBox = QtWidgets.QGroupBox("Grid layout")
+ layout = QtWidgets.QGridLayout()
for i in range(Dialog.NumGridRows):
- label = QtGui.QLabel("Line %d:" % (i + 1))
- lineEdit = QtGui.QLineEdit()
+ label = QtWidgets.QLabel("Line %d:" % (i + 1))
+ lineEdit = QtWidgets.QLineEdit()
layout.addWidget(label, i + 1, 0)
layout.addWidget(lineEdit, i + 1, 1)
- self.smallEditor = QtGui.QTextEdit()
+ self.smallEditor = QtWidgets.QTextEdit()
self.smallEditor.setPlainText("This widget takes up about two thirds "
"of the grid layout.")
@@ -77,11 +118,11 @@ class Dialog(QtGui.QDialog):
self.gridGroupBox.setLayout(layout)
def createFormGroupBox(self):
- self.formGroupBox = QtGui.QGroupBox("Form layout")
- layout = QtGui.QFormLayout()
- layout.addRow(QtGui.QLabel("Line 1:"), QtGui.QLineEdit())
- layout.addRow(QtGui.QLabel("Line 2, long text:"), QtGui.QComboBox())
- layout.addRow(QtGui.QLabel("Line 3:"), QtGui.QSpinBox())
+ self.formGroupBox = QtWidgets.QGroupBox("Form layout")
+ layout = QtWidgets.QFormLayout()
+ layout.addRow(QtWidgets.QLabel("Line 1:"), QtWidgets.QLineEdit())
+ layout.addRow(QtWidgets.QLabel("Line 2, long text:"), QtWidgets.QComboBox())
+ layout.addRow(QtWidgets.QLabel("Line 3:"), QtWidgets.QSpinBox())
self.formGroupBox.setLayout(layout)
@@ -89,6 +130,6 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
dialog = Dialog()
sys.exit(dialog.exec_())
diff --git a/examples/layouts/dynamiclayouts.py b/examples/layouts/dynamiclayouts.py
index 3b45649..6cb7320 100755
--- a/examples/layouts/dynamiclayouts.py
+++ b/examples/layouts/dynamiclayouts.py
@@ -1,12 +1,53 @@
#!/usr/bin/env python
-"""PySide port of the layouts/dynamiclayouts example from Qt v4.x"""
-
-from PySide.QtCore import Qt, QSize
-from PySide.QtGui import (QApplication, QDialog, QLayout, QGridLayout,
- QMessageBox, QGroupBox, QSpinBox, QSlider,
- QProgressBar, QDial, QDialogButtonBox,
- QComboBox, QLabel)
+############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/layouts/dynamiclayouts example from Qt v5.x"""
+
+from PySide2.QtCore import Qt, QSize
+from PySide2.QtWidgets import (QApplication, QDialog, QLayout, QGridLayout,
+ QMessageBox, QGroupBox, QSpinBox, QSlider,
+ QProgressBar, QDial, QDialogButtonBox,
+ QComboBox, QLabel)
class Dialog(QDialog):
def __init__(self):
diff --git a/examples/layouts/flowlayout.py b/examples/layouts/flowlayout.py
index 27f0bf9..75dfa46 100755
--- a/examples/layouts/flowlayout.py
+++ b/examples/layouts/flowlayout.py
@@ -1,26 +1,67 @@
#!/usr/bin/env python
-"""PyQt4 port of the layouts/flowlayout example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui
-
-
-class Window(QtGui.QWidget):
+############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/layouts/flowlayout example from Qt v5.x"""
+
+from PySide2 import QtCore, QtGui, QtWidgets
+
+
+class Window(QtWidgets.QWidget):
def __init__(self):
super(Window, self).__init__()
flowLayout = FlowLayout()
- flowLayout.addWidget(QtGui.QPushButton("Short"))
- flowLayout.addWidget(QtGui.QPushButton("Longer"))
- flowLayout.addWidget(QtGui.QPushButton("Different text"))
- flowLayout.addWidget(QtGui.QPushButton("More text"))
- flowLayout.addWidget(QtGui.QPushButton("Even longer button text"))
+ flowLayout.addWidget(QtWidgets.QPushButton("Short"))
+ flowLayout.addWidget(QtWidgets.QPushButton("Longer"))
+ flowLayout.addWidget(QtWidgets.QPushButton("Different text"))
+ flowLayout.addWidget(QtWidgets.QPushButton("More text"))
+ flowLayout.addWidget(QtWidgets.QPushButton("Even longer button text"))
self.setLayout(flowLayout)
self.setWindowTitle("Flow Layout")
-class FlowLayout(QtGui.QLayout):
+class FlowLayout(QtWidgets.QLayout):
def __init__(self, parent=None, margin=0, spacing=-1):
super(FlowLayout, self).__init__(parent)
@@ -87,8 +128,8 @@ class FlowLayout(QtGui.QLayout):
for item in self.itemList:
wid = item.widget()
- spaceX = self.spacing() + wid.style().layoutSpacing(QtGui.QSizePolicy.PushButton, QtGui.QSizePolicy.PushButton, QtCore.Qt.Horizontal)
- spaceY = self.spacing() + wid.style().layoutSpacing(QtGui.QSizePolicy.PushButton, QtGui.QSizePolicy.PushButton, QtCore.Qt.Vertical)
+ spaceX = self.spacing() + wid.style().layoutSpacing(QtWidgets.QSizePolicy.PushButton, QtWidgets.QSizePolicy.PushButton, QtCore.Qt.Horizontal)
+ spaceY = self.spacing() + wid.style().layoutSpacing(QtWidgets.QSizePolicy.PushButton, QtWidgets.QSizePolicy.PushButton, QtCore.Qt.Vertical)
nextX = x + item.sizeHint().width() + spaceX
if nextX - spaceX > rect.right() and lineHeight > 0:
x = rect.x()
@@ -109,7 +150,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
mainWin = Window()
mainWin.show()
sys.exit(app.exec_())
diff --git a/examples/mainwindows/README b/examples/mainwindows/README
index 329dd32..4d6018b 100644
--- a/examples/mainwindows/README
+++ b/examples/mainwindows/README
@@ -1,26 +1,26 @@
-All the standard features of application main windows are provided by PyQt.
+All the standard features of application main windows are provided by PySide2.
Main windows can have pull down menus, tool bars, and dock windows. These
separate forms of user input are unified in an integrated action system that
also supports keyboard shortcuts and accelerator keys in menu items.
-The example launcher provided with PyQt can be used to explore each of the
+The example launcher provided with PySide2 can be used to explore each of the
examples in this directory.
Documentation for these examples can be found via the Tutorial and Examples
link in the main Qt documentation.
-Finding the PyQt Examples and Demos launcher
+Finding the PySide2 Examples and Demos launcher
============================================
On Windows:
The launcher can be accessed via the Windows Start menu. Select the menu
-entry entitled "Examples and Demos" entry in the submenu containing PyQt4.
+entry entitled "Examples and Demos" entry in the submenu containing PySide2.
On all platforms:
The source code for the launcher can be found in the examples/demos/qtdemo
-directory in the PyQt package.
+directory in the PySide2 package.
diff --git a/examples/mainwindows/application/application.py b/examples/mainwindows/application/application.py
index 43605ff..f1f2ca7 100755
--- a/examples/mainwindows/application/application.py
+++ b/examples/mainwindows/application/application.py
@@ -1,21 +1,57 @@
#!/usr/bin/env python
-# This is only needed for Python v2 but is harmless for Python v3.
-#import sip
-#sip.setapi('QVariant', 2)
-
-from PySide2 import QtCore, QtGui
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui, QtWidgets
import application_rc
-
-class MainWindow(QtGui.QMainWindow):
+class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.curFile = ''
- self.textEdit = QtGui.QTextEdit()
+ self.textEdit = QtWidgets.QTextEdit()
self.setCentralWidget(self.textEdit)
self.createActions()
@@ -44,7 +80,7 @@ class MainWindow(QtGui.QMainWindow):
def open(self):
if self.maybeSave():
- fileName, filtr = QtGui.QFileDialog.getOpenFileName(self)
+ fileName, filtr = QtWidgets.QFileDialog.getOpenFileName(self)
if fileName:
self.loadFile(fileName)
@@ -55,14 +91,14 @@ class MainWindow(QtGui.QMainWindow):
return self.saveAs()
def saveAs(self):
- fileName, filtr = QtGui.QFileDialog.getSaveFileName(self)
+ fileName, filtr = QtWidgets.QFileDialog.getSaveFileName(self)
if fileName:
return self.saveFile(fileName)
return False
def about(self):
- QtGui.QMessageBox.about(self, "About Application",
+ QtWidgets.QMessageBox.about(self, "About Application",
"The <b>Application</b> example demonstrates how to write "
"modern GUI applications using Qt, with a menu bar, "
"toolbars, and a status bar.")
@@ -71,48 +107,48 @@ class MainWindow(QtGui.QMainWindow):
self.setWindowModified(self.textEdit.document().isModified())
def createActions(self):
- self.newAct = QtGui.QAction(QtGui.QIcon(':/images/new.png'), "&New",
+ self.newAct = QtWidgets.QAction(QtGui.QIcon(':/images/new.png'), "&New",
self, shortcut=QtGui.QKeySequence.New,
statusTip="Create a new file", triggered=self.newFile)
- self.openAct = QtGui.QAction(QtGui.QIcon(':/images/open.png'),
+ self.openAct = QtWidgets.QAction(QtGui.QIcon(':/images/open.png'),
"&Open...", self, shortcut=QtGui.QKeySequence.Open,
statusTip="Open an existing file", triggered=self.open)
- self.saveAct = QtGui.QAction(QtGui.QIcon(':/images/save.png'),
+ self.saveAct = QtWidgets.QAction(QtGui.QIcon(':/images/save.png'),
"&Save", self, shortcut=QtGui.QKeySequence.Save,
statusTip="Save the document to disk", triggered=self.save)
- self.saveAsAct = QtGui.QAction("Save &As...", self,
+ self.saveAsAct = QtWidgets.QAction("Save &As...", self,
shortcut=QtGui.QKeySequence.SaveAs,
statusTip="Save the document under a new name",
triggered=self.saveAs)
- self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q",
+ self.exitAct = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+Q",
statusTip="Exit the application", triggered=self.close)
- self.cutAct = QtGui.QAction(QtGui.QIcon(':/images/cut.png'), "Cu&t",
+ self.cutAct = QtWidgets.QAction(QtGui.QIcon(':/images/cut.png'), "Cu&t",
self, shortcut=QtGui.QKeySequence.Cut,
statusTip="Cut the current selection's contents to the clipboard",
triggered=self.textEdit.cut)
- self.copyAct = QtGui.QAction(QtGui.QIcon(':/images/copy.png'),
+ self.copyAct = QtWidgets.QAction(QtGui.QIcon(':/images/copy.png'),
"&Copy", self, shortcut=QtGui.QKeySequence.Copy,
statusTip="Copy the current selection's contents to the clipboard",
triggered=self.textEdit.copy)
- self.pasteAct = QtGui.QAction(QtGui.QIcon(':/images/paste.png'),
+ self.pasteAct = QtWidgets.QAction(QtGui.QIcon(':/images/paste.png'),
"&Paste", self, shortcut=QtGui.QKeySequence.Paste,
statusTip="Paste the clipboard's contents into the current selection",
triggered=self.textEdit.paste)
- self.aboutAct = QtGui.QAction("&About", self,
+ self.aboutAct = QtWidgets.QAction("&About", self,
statusTip="Show the application's About box",
triggered=self.about)
- self.aboutQtAct = QtGui.QAction("About &Qt", self,
+ self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
statusTip="Show the Qt library's About box",
- triggered=QtGui.qApp.aboutQt)
+ triggered=QtWidgets.qApp.aboutQt)
self.cutAct.setEnabled(False)
self.copyAct.setEnabled(False)
@@ -167,28 +203,28 @@ class MainWindow(QtGui.QMainWindow):
def maybeSave(self):
if self.textEdit.document().isModified():
- ret = QtGui.QMessageBox.warning(self, "Application",
+ ret = QtWidgets.QMessageBox.warning(self, "Application",
"The document has been modified.\nDo you want to save "
"your changes?",
- QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard |
- QtGui.QMessageBox.Cancel)
- if ret == QtGui.QMessageBox.Save:
+ QtWidgets.QMessageBox.Save | QtWidgets.QMessageBox.Discard |
+ QtWidgets.QMessageBox.Cancel)
+ if ret == QtWidgets.QMessageBox.Save:
return self.save()
- elif ret == QtGui.QMessageBox.Cancel:
+ elif ret == QtWidgets.QMessageBox.Cancel:
return False
return True
def loadFile(self, fileName):
file = QtCore.QFile(fileName)
if not file.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text):
- QtGui.QMessageBox.warning(self, "Application",
+ QtWidgets.QMessageBox.warning(self, "Application",
"Cannot read file %s:\n%s." % (fileName, file.errorString()))
return
inf = QtCore.QTextStream(file)
- QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
+ QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
self.textEdit.setPlainText(inf.readAll())
- QtGui.QApplication.restoreOverrideCursor()
+ QtWidgets.QApplication.restoreOverrideCursor()
self.setCurrentFile(fileName)
self.statusBar().showMessage("File loaded", 2000)
@@ -196,14 +232,16 @@ class MainWindow(QtGui.QMainWindow):
def saveFile(self, fileName):
file = QtCore.QFile(fileName)
if not file.open(QtCore.QFile.WriteOnly | QtCore.QFile.Text):
- QtGui.QMessageBox.warning(self, "Application",
+ QtWidgets.QMessageBox.warning(self, "Application",
"Cannot write file %s:\n%s." % (fileName, file.errorString()))
return False
outf = QtCore.QTextStream(file)
- QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
+ QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
+
+ # FIXME: Once file is out of scope, the file is empty, instead of having text.
outf << self.textEdit.toPlainText()
- QtGui.QApplication.restoreOverrideCursor()
+ QtWidgets.QApplication.restoreOverrideCursor()
self.setCurrentFile(fileName);
self.statusBar().showMessage("File saved", 2000)
@@ -229,7 +267,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
sys.exit(app.exec_())
diff --git a/examples/network/fortuneclient.py b/examples/network/fortuneclient.py
index c85ab50..3ec5623 100755
--- a/examples/network/fortuneclient.py
+++ b/examples/network/fortuneclient.py
@@ -1,40 +1,81 @@
#!/usr/bin/env python
-"""PySide port of the network/fortuneclient example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui, QtNetwork
-
-
-class Client(QtGui.QDialog):
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the network/fortuneclient example from Qt v5.x"""
+
+from PySide2 import QtCore, QtGui, QtWidgets, QtNetwork
+
+
+class Client(QtWidgets.QDialog):
def __init__(self, parent=None):
super(Client, self).__init__(parent)
self.blockSize = 0
self.currentFortune = ''
- hostLabel = QtGui.QLabel("&Server name:")
- portLabel = QtGui.QLabel("S&erver port:")
+ hostLabel = QtWidgets.QLabel("&Server name:")
+ portLabel = QtWidgets.QLabel("S&erver port:")
- self.hostLineEdit = QtGui.QLineEdit('Localhost')
- self.portLineEdit = QtGui.QLineEdit()
+ self.hostLineEdit = QtWidgets.QLineEdit('Localhost')
+ self.portLineEdit = QtWidgets.QLineEdit()
self.portLineEdit.setValidator(QtGui.QIntValidator(1, 65535, self))
hostLabel.setBuddy(self.hostLineEdit)
portLabel.setBuddy(self.portLineEdit)
- self.statusLabel = QtGui.QLabel("This examples requires that you run "
+ self.statusLabel = QtWidgets.QLabel("This examples requires that you run "
"the Fortune Server example as well.")
- self.getFortuneButton = QtGui.QPushButton("Get Fortune")
+ self.getFortuneButton = QtWidgets.QPushButton("Get Fortune")
self.getFortuneButton.setDefault(True)
self.getFortuneButton.setEnabled(False)
- quitButton = QtGui.QPushButton("Quit")
+ quitButton = QtWidgets.QPushButton("Quit")
- buttonBox = QtGui.QDialogButtonBox()
+ buttonBox = QtWidgets.QDialogButtonBox()
buttonBox.addButton(self.getFortuneButton,
- QtGui.QDialogButtonBox.ActionRole)
- buttonBox.addButton(quitButton, QtGui.QDialogButtonBox.RejectRole)
+ QtWidgets.QDialogButtonBox.ActionRole)
+ buttonBox.addButton(quitButton, QtWidgets.QDialogButtonBox.RejectRole)
self.tcpSocket = QtNetwork.QTcpSocket(self)
@@ -45,7 +86,7 @@ class Client(QtGui.QDialog):
self.tcpSocket.readyRead.connect(self.readFortune)
self.tcpSocket.error.connect(self.displayError)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(hostLabel, 0, 0)
mainLayout.addWidget(self.hostLineEdit, 0, 1)
mainLayout.addWidget(portLabel, 1, 0)
@@ -98,16 +139,16 @@ class Client(QtGui.QDialog):
if socketError == QtNetwork.QAbstractSocket.RemoteHostClosedError:
pass
elif socketError == QtNetwork.QAbstractSocket.HostNotFoundError:
- QtGui.QMessageBox.information(self, "Fortune Client",
+ QtWidgets.QMessageBox.information(self, "Fortune Client",
"The host was not found. Please check the host name and "
"port settings.")
elif socketError == QtNetwork.QAbstractSocket.ConnectionRefusedError:
- QtGui.QMessageBox.information(self, "Fortune Client",
+ QtWidgets.QMessageBox.information(self, "Fortune Client",
"The connection was refused by the peer. Make sure the "
"fortune server is running, and check that the host name "
"and port settings are correct.")
else:
- QtGui.QMessageBox.information(self, "Fortune Client",
+ QtWidgets.QMessageBox.information(self, "Fortune Client",
"The following error occurred: %s." % self.tcpSocket.errorString())
self.getFortuneButton.setEnabled(True)
@@ -121,7 +162,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
client = Client()
client.show()
sys.exit(client.exec_())
diff --git a/examples/network/fortuneserver.py b/examples/network/fortuneserver.py
index 504f623..1c08f6e 100755
--- a/examples/network/fortuneserver.py
+++ b/examples/network/fortuneserver.py
@@ -1,23 +1,64 @@
#!/usr/bin/env python
-"""PySide port of the network/fortuneserver example from Qt v4.x"""
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the network/fortuneserver example from Qt v5.x"""
import random
-from PySide2 import QtCore, QtGui, QtNetwork
+from PySide2 import QtCore, QtGui, QtWidgets, QtNetwork
-class Server(QtGui.QDialog):
+class Server(QtWidgets.QDialog):
def __init__(self, parent=None):
super(Server, self).__init__(parent)
- statusLabel = QtGui.QLabel()
- quitButton = QtGui.QPushButton("Quit")
+ statusLabel = QtWidgets.QLabel()
+ quitButton = QtWidgets.QPushButton("Quit")
quitButton.setAutoDefault(False)
self.tcpServer = QtNetwork.QTcpServer(self)
if not self.tcpServer.listen():
- QtGui.QMessageBox.critical(self, "Fortune Server",
+ QtWidgets.QMessageBox.critical(self, "Fortune Server",
"Unable to start the server: %s." % self.tcpServer.errorString())
self.close()
return
@@ -37,12 +78,12 @@ class Server(QtGui.QDialog):
quitButton.clicked.connect(self.close)
self.tcpServer.newConnection.connect(self.sendFortune)
- buttonLayout = QtGui.QHBoxLayout()
+ buttonLayout = QtWidgets.QHBoxLayout()
buttonLayout.addStretch(1)
buttonLayout.addWidget(quitButton)
buttonLayout.addStretch(1)
- mainLayout = QtGui.QVBoxLayout()
+ mainLayout = QtWidgets.QVBoxLayout()
mainLayout.addWidget(statusLabel)
mainLayout.addLayout(buttonLayout)
self.setLayout(mainLayout)
@@ -78,7 +119,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
server = Server()
random.seed(None)
sys.exit(server.exec_())
diff --git a/examples/richtext/orderform.py b/examples/richtext/orderform.py
index 423725a..e068db2 100755
--- a/examples/richtext/orderform.py
+++ b/examples/richtext/orderform.py
@@ -1,15 +1,56 @@
#!/usr/bin/env python
-"""PyQt4 port of the richtext/orderform example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui
-
-
-class MainWindow(QtGui.QMainWindow):
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/richtext/orderform example from Qt v5.x"""
+
+from PySide2 import QtCore, QtGui, QtWidgets, QtPrintSupport
+
+
+class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
- fileMenu = QtGui.QMenu("&File", self)
+ fileMenu = QtWidgets.QMenu("&File", self)
newAction = fileMenu.addAction("&New...")
newAction.setShortcut("Ctrl+N")
self.printAction = fileMenu.addAction("&Print...", self.printFile)
@@ -19,7 +60,7 @@ class MainWindow(QtGui.QMainWindow):
quitAction.setShortcut("Ctrl+Q")
self.menuBar().addMenu(fileMenu)
- self.letters = QtGui.QTabWidget()
+ self.letters = QtWidgets.QTabWidget()
newAction.triggered.connect(self.openDialog)
quitAction.triggered.connect(self.close)
@@ -28,7 +69,7 @@ class MainWindow(QtGui.QMainWindow):
self.setWindowTitle("Order Form")
def createLetter(self, name, address, orderItems, sendOffers):
- editor = QtGui.QTextEdit()
+ editor = QtWidgets.QTextEdit()
tabIndex = self.letters.addTab(editor, name)
self.letters.setCurrentIndex(tabIndex)
@@ -147,49 +188,49 @@ class MainWindow(QtGui.QMainWindow):
def openDialog(self):
dialog = DetailsDialog("Enter Customer Details", self)
- if dialog.exec_() == QtGui.QDialog.Accepted:
+ if dialog.exec_() == QtWidgets.QDialog.Accepted:
self.createLetter(dialog.senderName(), dialog.senderAddress(),
dialog.orderItems(), dialog.sendOffers())
def printFile(self):
editor = self.letters.currentWidget()
- printer = QtGui.QPrinter()
+ printer = QtPrintSupport.QPrinter()
- dialog = QtGui.QPrintDialog(printer, self)
+ dialog = QtPrintSupport.QPrintDialog(printer, self)
dialog.setWindowTitle("Print Document")
if editor.textCursor().hasSelection():
- dialog.addEnabledOption(QtGui.QAbstractPrintDialog.PrintSelection)
+ dialog.addEnabledOption(QtPrintSupport.QAbstractPrintDialog.PrintSelection)
- if dialog.exec_() != QtGui.QDialog.Accepted:
+ if dialog.exec_() != QtWidgets.QDialog.Accepted:
return
editor.print_(printer)
-class DetailsDialog(QtGui.QDialog):
+class DetailsDialog(QtWidgets.QDialog):
def __init__(self, title, parent):
super(DetailsDialog, self).__init__(parent)
self.items = ("T-shirt", "Badge", "Reference book", "Coffee cup")
- nameLabel = QtGui.QLabel("Name:")
- addressLabel = QtGui.QLabel("Address:")
+ nameLabel = QtWidgets.QLabel("Name:")
+ addressLabel = QtWidgets.QLabel("Address:")
addressLabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
- self.nameEdit = QtGui.QLineEdit()
- self.addressEdit = QtGui.QTextEdit()
- self.offersCheckBox = QtGui.QCheckBox("Send information about "
+ self.nameEdit = QtWidgets.QLineEdit()
+ self.addressEdit = QtWidgets.QTextEdit()
+ self.offersCheckBox = QtWidgets.QCheckBox("Send information about "
"products and special offers:")
self.setupItemsTable()
- buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
+ buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
buttonBox.accepted.connect(self.verify)
buttonBox.rejected.connect(self.reject)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameEdit, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0)
@@ -202,13 +243,13 @@ class DetailsDialog(QtGui.QDialog):
self.setWindowTitle(title)
def setupItemsTable(self):
- self.itemsTable = QtGui.QTableWidget(len(self.items), 2)
+ self.itemsTable = QtWidgets.QTableWidget(len(self.items), 2)
for row, item in enumerate(self.items):
- name = QtGui.QTableWidgetItem(item)
+ name = QtWidgets.QTableWidgetItem(item)
name.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
self.itemsTable.setItem(row, 0, name)
- quantity = QtGui.QTableWidgetItem('1')
+ quantity = QtWidgets.QTableWidgetItem('1')
self.itemsTable.setItem(row, 1, quantity)
def orderItems(self):
@@ -235,12 +276,12 @@ class DetailsDialog(QtGui.QDialog):
self.accept()
return
- answer = QtGui.QMessageBox.warning(self, "Incomplete Form",
+ answer = QtWidgets.QMessageBox.warning(self, "Incomplete Form",
"The form does not contain all the necessary information.\n"
"Do you want to discard it?",
- QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
+ QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
- if answer == QtGui.QMessageBox.Yes:
+ if answer == QtWidgets.QMessageBox.Yes:
self.reject()
@@ -248,7 +289,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.resize(640, 480)
window.show()
diff --git a/examples/richtext/syntaxhighlighter.py b/examples/richtext/syntaxhighlighter.py
index afae910..8a14632 100755
--- a/examples/richtext/syntaxhighlighter.py
+++ b/examples/richtext/syntaxhighlighter.py
@@ -1,11 +1,52 @@
#!/usr/bin/env python
-"""PyQt4 port of the richtext/syntaxhighlighter example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui
-
-
-class MainWindow(QtGui.QMainWindow):
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/richtext/syntaxhighlighter example from Qt v5.x"""
+
+from PySide2 import QtCore, QtGui, QtWidgets
+
+
+class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
@@ -17,7 +58,7 @@ class MainWindow(QtGui.QMainWindow):
self.setWindowTitle("Syntax Highlighter")
def about(self):
- QtGui.QMessageBox.about(self, "About Syntax Highlighter",
+ QtWidgets.QMessageBox.about(self, "About Syntax Highlighter",
"<p>The <b>Syntax Highlighter</b> example shows how to " \
"perform simple syntax highlighting by subclassing the " \
"QSyntaxHighlighter class and describing highlighting " \
@@ -28,7 +69,7 @@ class MainWindow(QtGui.QMainWindow):
def openFile(self, path=None):
if not path:
- path = QtGui.QFileDialog.getOpenFileName(self, "Open File",
+ path = QtWidgets.QFileDialog.getOpenFileName(self, "Open File",
'', "C++ Files (*.cpp *.h)")
if path:
@@ -51,25 +92,25 @@ class MainWindow(QtGui.QMainWindow):
font.setFixedPitch(True)
font.setPointSize(10)
- self.editor = QtGui.QTextEdit()
+ self.editor = QtWidgets.QTextEdit()
self.editor.setFont(font)
self.highlighter = Highlighter(self.editor.document())
def setupFileMenu(self):
- fileMenu = QtGui.QMenu("&File", self)
+ fileMenu = QtWidgets.QMenu("&File", self)
self.menuBar().addMenu(fileMenu)
fileMenu.addAction("&New...", self.newFile, "Ctrl+N")
fileMenu.addAction("&Open...", self.openFile, "Ctrl+O")
- fileMenu.addAction("E&xit", QtGui.qApp.quit, "Ctrl+Q")
+ fileMenu.addAction("E&xit", QtWidgets.qApp.quit, "Ctrl+Q")
def setupHelpMenu(self):
- helpMenu = QtGui.QMenu("&Help", self)
+ helpMenu = QtWidgets.QMenu("&Help", self)
self.menuBar().addMenu(helpMenu)
helpMenu.addAction("&About", self.about)
- helpMenu.addAction("About &Qt", QtGui.qApp.aboutQt)
+ helpMenu.addAction("About &Qt", QtWidgets.qApp.aboutQt)
class Highlighter(QtGui.QSyntaxHighlighter):
@@ -155,7 +196,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.resize(640, 512)
window.show()
diff --git a/examples/richtext/syntaxhighlighter/syntaxhighlighter.py b/examples/richtext/syntaxhighlighter/syntaxhighlighter.py
index abde257..4b3fe83 100755
--- a/examples/richtext/syntaxhighlighter/syntaxhighlighter.py
+++ b/examples/richtext/syntaxhighlighter/syntaxhighlighter.py
@@ -1,17 +1,58 @@
#!/usr/bin/env python
-"""PySide port of the richtext/syntaxhighlighter example from Qt v4.x"""
+############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/richtext/syntaxhighlighter example from Qt v5.x"""
import sys
import re
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
import syntaxhighlighter_rc
-class MainWindow(QtGui.QMainWindow):
+class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
- QtGui.QMainWindow.__init__(self, parent)
+ QtWidgets.QMainWindow.__init__(self, parent)
self.highlighter = Highlighter()
@@ -28,7 +69,7 @@ class MainWindow(QtGui.QMainWindow):
fileName = path
if fileName=="":
- fileName,_ = QtGui.QFileDialog.getOpenFileName(self, self.tr("Open File"), "",
+ fileName,_ = QtWidgets.QFileDialog.getOpenFileName(self, self.tr("Open File"), "",
"qmake Files (*.pro *.prf *.pri)")
if fileName!="":
@@ -61,25 +102,25 @@ class MainWindow(QtGui.QMainWindow):
font.setFixedPitch(True)
font.setPointSize(10)
- self.editor = QtGui.QTextEdit()
+ self.editor = QtWidgets.QTextEdit()
self.editor.setFont(font)
self.highlighter.addToDocument(self.editor.document())
def setupFileMenu(self):
- fileMenu = QtGui.QMenu(self.tr("&File"), self)
+ fileMenu = QtWidgets.QMenu(self.tr("&File"), self)
self.menuBar().addMenu(fileMenu)
- newFileAct = QtGui.QAction(self.tr("&New..."), self)
+ newFileAct = QtWidgets.QAction(self.tr("&New..."), self)
newFileAct.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+N", "File|New")))
self.connect(newFileAct, QtCore.SIGNAL("triggered()"), self.newFile)
fileMenu.addAction(newFileAct)
- openFileAct = QtGui.QAction(self.tr("&Open..."), self)
+ openFileAct = QtWidgets.QAction(self.tr("&Open..."), self)
openFileAct.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+O", "File|Open")))
self.connect(openFileAct, QtCore.SIGNAL("triggered()"), self.openFile)
fileMenu.addAction(openFileAct)
- fileMenu.addAction(self.tr("E&xit"), QtGui.qApp, QtCore.SLOT("quit()"),
+ fileMenu.addAction(self.tr("E&xit"), QtWidgets.qApp, QtCore.SLOT("quit()"),
QtGui.QKeySequence(self.tr("Ctrl+Q", "File|Exit")))
@@ -131,7 +172,7 @@ class Highlighter(QtCore.QObject):
if __name__ == '__main__':
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.resize(640, 512)
window.show()
diff --git a/examples/richtext/textobject/textobject.py b/examples/richtext/textobject/textobject.py
index dc3dcd4..3e7b75d 100755
--- a/examples/richtext/textobject/textobject.py
+++ b/examples/richtext/textobject/textobject.py
@@ -1,8 +1,49 @@
#!/usr/bin/env python
-"""PyQt4 port of the richtext/textobject example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui, QtSvg
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/richtext/textobject example from Qt v5.x"""
+
+from PySide2 import QtCore, QtGui, QtWidgets, QtSvg
class SvgTextObject(QtCore.QObject, QtGui.QTextObjectInterface):
@@ -21,7 +62,7 @@ class SvgTextObject(QtCore.QObject, QtGui.QTextObjectInterface):
renderer.render(painter, rect)
-class Window(QtGui.QWidget):
+class Window(QtWidgets.QWidget):
SvgTextFormat = QtGui.QTextFormat.UserObject + 1
@@ -40,7 +81,7 @@ class Window(QtGui.QWidget):
file = QtCore.QFile(fileName)
if not file.open(QtCore.QIODevice.ReadOnly):
- QtGui.QMessageBox.warning(self, self.tr("Error Opening File"),
+ QtWidgets.QMessageBox.warning(self, self.tr("Error Opening File"),
self.tr("Could not open '%1'").arg(fileName))
svgData = file.readAll()
@@ -58,21 +99,21 @@ class Window(QtGui.QWidget):
self.textEdit.document().documentLayout().registerHandler(Window.SvgTextFormat, svgInterface)
def setupGui(self):
- fileNameLabel = QtGui.QLabel(self.tr("Svg File Name:"))
- self.fileNameLineEdit = QtGui.QLineEdit()
- insertTextObjectButton = QtGui.QPushButton(self.tr("Insert Image"))
+ fileNameLabel = QtWidgets.QLabel(self.tr("Svg File Name:"))
+ self.fileNameLineEdit = QtWidgets.QLineEdit()
+ insertTextObjectButton = QtWidgets.QPushButton(self.tr("Insert Image"))
self.fileNameLineEdit.setText('./files/heart.svg')
QtCore.QObject.connect(insertTextObjectButton, QtCore.SIGNAL('clicked()'), self.insertTextObject)
- bottomLayout = QtGui.QHBoxLayout()
+ bottomLayout = QtWidgets.QHBoxLayout()
bottomLayout.addWidget(fileNameLabel)
bottomLayout.addWidget(self.fileNameLineEdit)
bottomLayout.addWidget(insertTextObjectButton)
- self.textEdit = QtGui.QTextEdit()
+ self.textEdit = QtWidgets.QTextEdit()
- mainLayout = QtGui.QVBoxLayout()
+ mainLayout = QtWidgets.QVBoxLayout()
mainLayout.addWidget(self.textEdit)
mainLayout.addLayout(bottomLayout)
@@ -83,7 +124,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
diff --git a/examples/script/helloscript.py b/examples/script/helloscript.py
index 7974b95..5ae659f 100755
--- a/examples/script/helloscript.py
+++ b/examples/script/helloscript.py
@@ -1,20 +1,60 @@
#!/usr/bin/env python
-"""PySide port of the script/helloscript example from Qt v4.x"""
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the script/helloscript example from Qt v5.x"""
import sys
-from PySide2 import QtGui, QtScript
+from PySide2 import QtWidgets, QtScript
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
engine = QtScript.QScriptEngine()
-button = QtGui.QPushButton()
+button = QtWidgets.QPushButton()
scriptButton = engine.newQObject(button)
engine.globalObject().setProperty("button", scriptButton)
-engine.evaluate("button.text = 'Hello World!'")
+engine.evaluate("button.text = 'Hello World from PySide2!'")
engine.evaluate("button.styleSheet = 'font-style: italic'")
engine.evaluate("button.show()")
diff --git a/examples/state-machine/eventtrans.py b/examples/state-machine/eventtrans.py
index ad56c2f..68e21a8 100755
--- a/examples/state-machine/eventtrans.py
+++ b/examples/state-machine/eventtrans.py
@@ -1,8 +1,48 @@
#!/usr/bin/env python
-#Author velociraptor Genjix <aphidia@hotmail.com>
-from PySide.QtGui import *
-from PySide.QtCore import *
+#############################################################################
+##
+## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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.QtWidgets import *
+from PySide2.QtCore import *
class MainWindow(QMainWindow):
def __init__(self):
diff --git a/examples/state-machine/factstates.py b/examples/state-machine/factstates.py
index b9fdec8..8550c3f 100755
--- a/examples/state-machine/factstates.py
+++ b/examples/state-machine/factstates.py
@@ -1,8 +1,48 @@
#!/usr/bin/env python
-#Author velociraptor Genjix <aphidia@hotmail.com>
-from PySide.QtGui import *
-from PySide.QtCore import *
+#############################################################################
+##
+## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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.QtWidgets import *
+from PySide2.QtCore import *
class Factorial(QObject):
xChanged = Signal(int)
diff --git a/examples/state-machine/pingpong.py b/examples/state-machine/pingpong.py
index bc000a3..f0233ff 100755
--- a/examples/state-machine/pingpong.py
+++ b/examples/state-machine/pingpong.py
@@ -1,8 +1,48 @@
#!/usr/bin/env python
-#Author velociraptor Genjix <aphidia@hotmail.com>
-from PySide.QtGui import *
-from PySide.QtCore import *
+#############################################################################
+##
+## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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.QtWidgets import *
+from PySide2.QtCore import *
class PingEvent(QEvent):
def __init__(self):
diff --git a/examples/state-machine/rogue.py b/examples/state-machine/rogue.py
index 217cdd6..e6ab3fa 100755
--- a/examples/state-machine/rogue.py
+++ b/examples/state-machine/rogue.py
@@ -1,8 +1,49 @@
#!/usr/bin/env python
-#Author velociraptor Genjix <aphidia@hotmail.com>
-from PySide.QtGui import *
-from PySide.QtCore import *
+#############################################################################
+##
+## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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.QtWidgets import *
+from PySide2.QtGui import *
+from PySide2.QtCore import *
class MovementTransition(QEventTransition):
def __init__(self, window):
diff --git a/examples/state-machine/trafficlight.py b/examples/state-machine/trafficlight.py
index af27977..560417b 100755
--- a/examples/state-machine/trafficlight.py
+++ b/examples/state-machine/trafficlight.py
@@ -1,8 +1,49 @@
#!/usr/bin/env python
-#Author velociraptor Genjix <aphidia@hotmail.com>
-from PySide.QtGui import *
-from PySide.QtCore import *
+#############################################################################
+##
+## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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.QtWidgets import *
+from PySide2.QtGui import *
+from PySide2.QtCore import *
class LightWidget(QWidget):
def __init__(self, colour):
diff --git a/examples/state-machine/twowaybutton.py b/examples/state-machine/twowaybutton.py
index da74e09..6b27787 100755
--- a/examples/state-machine/twowaybutton.py
+++ b/examples/state-machine/twowaybutton.py
@@ -1,9 +1,48 @@
#!/usr/bin/env python
-#Author velociraptor Genjix <aphidia@hotmail.com>
+#############################################################################
+##
+## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 PySide.QtGui import *
-from PySide.QtCore import *
+from PySide2.QtWidgets import *
+from PySide2.QtCore import *
if __name__ == '__main__':
import sys
diff --git a/examples/tools/codecs/codecs.py b/examples/tools/codecs/codecs.py
index fc990fe..15f7d95 100755
--- a/examples/tools/codecs/codecs.py
+++ b/examples/tools/codecs/codecs.py
@@ -1,8 +1,49 @@
#!/usr/bin/env python
-"""PyQt4 port of the tools/codecs example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/tools/codecs example from Qt v5.x"""
+
+from PySide2 import QtCore, QtGui, QtWidgets
def codec_name(codec):
@@ -16,12 +57,12 @@ def codec_name(codec):
return name
-class MainWindow(QtGui.QMainWindow):
+class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
- self.textEdit = QtGui.QTextEdit()
- self.textEdit.setLineWrapMode(QtGui.QTextEdit.NoWrap)
+ self.textEdit = QtWidgets.QTextEdit()
+ self.textEdit.setLineWrapMode(QtWidgets.QTextEdit.NoWrap)
self.setCentralWidget(self.textEdit)
self.codecs = []
@@ -38,11 +79,11 @@ class MainWindow(QtGui.QMainWindow):
self.resize(500, 400)
def open(self):
- fileName, _ = QtGui.QFileDialog.getOpenFileName(self)
+ fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self)
if fileName:
inFile = QtCore.QFile(fileName)
if not inFile.open(QtCore.QFile.ReadOnly):
- QtGui.QMessageBox.warning(self, "Codecs",
+ QtWidgets.QMessageBox.warning(self, "Codecs",
"Cannot read file %s:\n%s" % (fileName, inFile.errorString()))
return
@@ -53,11 +94,11 @@ class MainWindow(QtGui.QMainWindow):
self.textEdit.setPlainText(self.previewForm.decodedString())
def save(self):
- fileName = QtGui.QFileDialog.getSaveFileName(self)
+ fileName = QtWidgets.QFileDialog.getSaveFileName(self)
if fileName:
outFile = QtCore.QFile(fileName)
if not outFile.open(QtCore.QFile.WriteOnly|QtCore.QFile.Text):
- QtGui.QMessageBox.warning(self, "Codecs",
+ QtWidgets.QMessageBox.warning(self, "Codecs",
"Cannot write file %s:\n%s" % (fileName, outFile.errorString()))
return
@@ -69,7 +110,7 @@ class MainWindow(QtGui.QMainWindow):
out << self.textEdit.toPlainText()
def about(self):
- QtGui.QMessageBox.about(self, "About Codecs",
+ QtWidgets.QMessageBox.about(self, "About Codecs",
"The <b>Codecs</b> example demonstrates how to read and "
"write files using various encodings.")
@@ -108,38 +149,38 @@ class MainWindow(QtGui.QMainWindow):
self.codecs = [item[-1] for item in codecMap]
def createActions(self):
- self.openAct = QtGui.QAction("&Open...", self, shortcut="Ctrl+O",
+ self.openAct = QtWidgets.QAction("&Open...", self, shortcut="Ctrl+O",
triggered=self.open)
for codec in self.codecs:
name = codec_name(codec)
- action = QtGui.QAction(name + '...', self, triggered=self.save)
+ action = QtWidgets.QAction(name + '...', self, triggered=self.save)
action.setData(name)
self.saveAsActs.append(action)
- self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q",
+ self.exitAct = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+Q",
triggered=self.close)
- self.aboutAct = QtGui.QAction("&About", self, triggered=self.about)
+ self.aboutAct = QtWidgets.QAction("&About", self, triggered=self.about)
- self.aboutQtAct = QtGui.QAction("About &Qt", self,
- triggered=QtGui.qApp.aboutQt)
+ self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
+ triggered=QtWidgets.qApp.aboutQt)
def createMenus(self):
- self.saveAsMenu = QtGui.QMenu("&Save As", self)
+ self.saveAsMenu = QtWidgets.QMenu("&Save As", self)
for action in self.saveAsActs:
self.saveAsMenu.addAction(action)
self.saveAsMenu.aboutToShow.connect(self.aboutToShowSaveAsMenu)
- self.fileMenu = QtGui.QMenu("&File", self)
+ self.fileMenu = QtWidgets.QMenu("&File", self)
self.fileMenu.addAction(self.openAct)
self.fileMenu.addMenu(self.saveAsMenu)
self.fileMenu.addSeparator()
self.fileMenu.addAction(self.exitAct)
- self.helpMenu = QtGui.QMenu("&Help", self)
+ self.helpMenu = QtWidgets.QMenu("&Help", self)
self.helpMenu.addAction(self.aboutAct)
self.helpMenu.addAction(self.aboutQtAct)
@@ -148,25 +189,25 @@ class MainWindow(QtGui.QMainWindow):
self.menuBar().addMenu(self.helpMenu)
-class PreviewForm(QtGui.QDialog):
+class PreviewForm(QtWidgets.QDialog):
def __init__(self, parent):
super(PreviewForm, self).__init__(parent)
- self.encodingComboBox = QtGui.QComboBox()
- encodingLabel = QtGui.QLabel("&Encoding:")
+ self.encodingComboBox = QtWidgets.QComboBox()
+ encodingLabel = QtWidgets.QLabel("&Encoding:")
encodingLabel.setBuddy(self.encodingComboBox)
- self.textEdit = QtGui.QTextEdit()
- self.textEdit.setLineWrapMode(QtGui.QTextEdit.NoWrap)
+ self.textEdit = QtWidgets.QTextEdit()
+ self.textEdit.setLineWrapMode(QtWidgets.QTextEdit.NoWrap)
self.textEdit.setReadOnly(True)
- buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
+ buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
self.encodingComboBox.activated.connect(self.updateTextEdit)
buttonBox.accepted.connect(self.accept)
buttonBox.rejected.connect(self.reject)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(encodingLabel, 0, 0)
mainLayout.addWidget(self.encodingComboBox, 0, 1)
mainLayout.addWidget(self.textEdit, 1, 0, 1, 2)
@@ -204,7 +245,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
sys.exit(app.exec_())
diff --git a/examples/tools/regexp.py b/examples/tools/regexp.py
index 1c7bbfc..7e28a53 100755
--- a/examples/tools/regexp.py
+++ b/examples/tools/regexp.py
@@ -1,35 +1,76 @@
#!/usr/bin/env python
-"""PyQt4 port of the tools/regexp example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui
-
-
-class RegExpDialog(QtGui.QDialog):
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/tools/regexp example from Qt v5.x"""
+
+from PySide2 import QtCore, QtGui, QtWidgets
+
+
+class RegExpDialog(QtWidgets.QDialog):
MaxCaptures = 6
def __init__(self, parent=None):
super(RegExpDialog, self).__init__(parent)
- self.patternComboBox = QtGui.QComboBox()
+ self.patternComboBox = QtWidgets.QComboBox()
self.patternComboBox.setEditable(True)
- self.patternComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
- QtGui.QSizePolicy.Preferred)
+ self.patternComboBox.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
+ QtWidgets.QSizePolicy.Preferred)
- patternLabel = QtGui.QLabel("&Pattern:")
+ patternLabel = QtWidgets.QLabel("&Pattern:")
patternLabel.setBuddy(self.patternComboBox)
- self.escapedPatternLineEdit = QtGui.QLineEdit()
+ self.escapedPatternLineEdit = QtWidgets.QLineEdit()
self.escapedPatternLineEdit.setReadOnly(True)
palette = self.escapedPatternLineEdit.palette()
palette.setBrush(QtGui.QPalette.Base,
palette.brush(QtGui.QPalette.Disabled, QtGui.QPalette.Base))
self.escapedPatternLineEdit.setPalette(palette)
- escapedPatternLabel = QtGui.QLabel("&Escaped Pattern:")
+ escapedPatternLabel = QtWidgets.QLabel("&Escaped Pattern:")
escapedPatternLabel.setBuddy(self.escapedPatternLineEdit)
- self.syntaxComboBox = QtGui.QComboBox()
+ self.syntaxComboBox = QtWidgets.QComboBox()
self.syntaxComboBox.addItem("Regular expression v1",
QtCore.QRegExp.RegExp)
self.syntaxComboBox.addItem("Regular expression v2",
@@ -38,43 +79,43 @@ class RegExpDialog(QtGui.QDialog):
self.syntaxComboBox.addItem("Fixed string",
QtCore.QRegExp.FixedString)
- syntaxLabel = QtGui.QLabel("&Pattern Syntax:")
+ syntaxLabel = QtWidgets.QLabel("&Pattern Syntax:")
syntaxLabel.setBuddy(self.syntaxComboBox)
- self.textComboBox = QtGui.QComboBox()
+ self.textComboBox = QtWidgets.QComboBox()
self.textComboBox.setEditable(True)
- self.textComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
- QtGui.QSizePolicy.Preferred)
+ self.textComboBox.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
+ QtWidgets.QSizePolicy.Preferred)
- textLabel = QtGui.QLabel("&Text:")
+ textLabel = QtWidgets.QLabel("&Text:")
textLabel.setBuddy(self.textComboBox)
- self.caseSensitiveCheckBox = QtGui.QCheckBox("Case &Sensitive")
+ self.caseSensitiveCheckBox = QtWidgets.QCheckBox("Case &Sensitive")
self.caseSensitiveCheckBox.setChecked(True)
- self.minimalCheckBox = QtGui.QCheckBox("&Minimal")
+ self.minimalCheckBox = QtWidgets.QCheckBox("&Minimal")
- indexLabel = QtGui.QLabel("Index of Match:")
- self.indexEdit = QtGui.QLineEdit()
+ indexLabel = QtWidgets.QLabel("Index of Match:")
+ self.indexEdit = QtWidgets.QLineEdit()
self.indexEdit.setReadOnly(True)
- matchedLengthLabel = QtGui.QLabel("Matched Length:")
- self.matchedLengthEdit = QtGui.QLineEdit()
+ matchedLengthLabel = QtWidgets.QLabel("Matched Length:")
+ self.matchedLengthEdit = QtWidgets.QLineEdit()
self.matchedLengthEdit.setReadOnly(True)
self.captureLabels = []
self.captureEdits = []
for i in range(self.MaxCaptures):
- self.captureLabels.append(QtGui.QLabel("Capture %d:" % i))
- self.captureEdits.append(QtGui.QLineEdit())
+ self.captureLabels.append(QtWidgets.QLabel("Capture %d:" % i))
+ self.captureEdits.append(QtWidgets.QLineEdit())
self.captureEdits[i].setReadOnly(True)
self.captureLabels[0].setText("Match:")
- checkBoxLayout = QtGui.QHBoxLayout()
+ checkBoxLayout = QtWidgets.QHBoxLayout()
checkBoxLayout.addWidget(self.caseSensitiveCheckBox)
checkBoxLayout.addWidget(self.minimalCheckBox)
checkBoxLayout.addStretch(1)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(patternLabel, 0, 0)
mainLayout.addWidget(self.patternComboBox, 0, 1)
mainLayout.addWidget(escapedPatternLabel, 1, 0)
@@ -139,8 +180,8 @@ class RegExpDialog(QtGui.QDialog):
self.matchedLengthEdit.setText(str(rx.matchedLength()))
for i in range(self.MaxCaptures):
- self.captureLabels[i].setEnabled(i <= rx.numCaptures())
- self.captureEdits[i].setEnabled(i <= rx.numCaptures())
+ self.captureLabels[i].setEnabled(i <= rx.captureCount())
+ self.captureEdits[i].setEnabled(i <= rx.captureCount())
self.captureEdits[i].setText(rx.cap(i))
self.setUpdatesEnabled(True)
@@ -149,6 +190,6 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
dialog = RegExpDialog()
sys.exit(dialog.exec_())
diff --git a/examples/tools/settingseditor/settingseditor.py b/examples/tools/settingseditor/settingseditor.py
index 1398650..9050497 100755
--- a/examples/tools/settingseditor/settingseditor.py
+++ b/examples/tools/settingseditor/settingseditor.py
@@ -1,13 +1,54 @@
#!/usr/bin/env python
-"""PyQt4 port of the tools/settingseditor example from Qt v4.x"""
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/tools/settingseditor example from Qt v5.x"""
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class MainWindow(QtGui.QMainWindow):
+class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
@@ -38,7 +79,7 @@ class MainWindow(QtGui.QMainWindow):
self.fallbacksAct.setEnabled(True)
def openIniFile(self):
- fileName, _ = QtGui.QFileDialog.getOpenFileName(self, "Open INI File",
+ fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Open INI File",
'', "INI Files (*.ini *.conf)")
if fileName:
@@ -47,7 +88,7 @@ class MainWindow(QtGui.QMainWindow):
self.fallbacksAct.setEnabled(False)
def openPropertyList(self):
- fileName, _ = QtGui.QFileDialog.getOpenFileName(self,
+ fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self,
"Open Property List", '', "Property List Files (*.plist)")
if fileName:
@@ -56,9 +97,9 @@ class MainWindow(QtGui.QMainWindow):
self.fallbacksAct.setEnabled(False)
def openRegistryPath(self):
- path, ok = QtGui.QInputDialog.getText(self, "Open Registry Path",
+ path, ok = QtWidgets.QInputDialog.getText(self, "Open Registry Path",
"Enter the path in the Windows registry:",
- QtGui.QLineEdit.Normal, 'HKEY_CURRENT_USER\\')
+ QtWidgets.QLineEdit.Normal, 'HKEY_CURRENT_USER\\')
if ok and path != '':
settings = QtCore.QSettings(path, QtCore.QSettings.NativeFormat)
@@ -66,47 +107,47 @@ class MainWindow(QtGui.QMainWindow):
self.fallbacksAct.setEnabled(False)
def about(self):
- QtGui.QMessageBox.about(self, "About Settings Editor",
+ QtWidgets.QMessageBox.about(self, "About Settings Editor",
"The <b>Settings Editor</b> example shows how to access "
"application settings using Qt.")
def createActions(self):
- self.openSettingsAct = QtGui.QAction("&Open Application Settings...",
+ self.openSettingsAct = QtWidgets.QAction("&Open Application Settings...",
self, shortcut="Ctrl+O", triggered=self.openSettings)
- self.openIniFileAct = QtGui.QAction("Open I&NI File...", self,
+ self.openIniFileAct = QtWidgets.QAction("Open I&NI File...", self,
shortcut="Ctrl+N", triggered=self.openIniFile)
- self.openPropertyListAct = QtGui.QAction("Open Mac &Property List...",
+ self.openPropertyListAct = QtWidgets.QAction("Open macOS &Property List...",
self, shortcut="Ctrl+P", triggered=self.openPropertyList)
if sys.platform != 'darwin':
self.openPropertyListAct.setEnabled(False)
- self.openRegistryPathAct = QtGui.QAction(
+ self.openRegistryPathAct = QtWidgets.QAction(
"Open Windows &Registry Path...", self, shortcut="Ctrl+G",
triggered=self.openRegistryPath)
if sys.platform != 'win32':
self.openRegistryPathAct.setEnabled(False)
- self.refreshAct = QtGui.QAction("&Refresh", self, shortcut="Ctrl+R",
+ self.refreshAct = QtWidgets.QAction("&Refresh", self, shortcut="Ctrl+R",
enabled=False, triggered=self.settingsTree.refresh)
- self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q",
+ self.exitAct = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+Q",
triggered=self.close)
- self.autoRefreshAct = QtGui.QAction("&Auto-Refresh", self,
+ self.autoRefreshAct = QtWidgets.QAction("&Auto-Refresh", self,
shortcut="Ctrl+A", checkable=True, enabled=False)
self.autoRefreshAct.triggered[bool].connect(self.settingsTree.setAutoRefresh)
self.autoRefreshAct.triggered[bool].connect(self.refreshAct.setDisabled)
- self.fallbacksAct = QtGui.QAction("&Fallbacks", self,
+ self.fallbacksAct = QtWidgets.QAction("&Fallbacks", self,
shortcut="Ctrl+F", checkable=True, enabled=False)
self.fallbacksAct.triggered[bool].connect(self.settingsTree.setFallbacksEnabled)
- self.aboutAct = QtGui.QAction("&About", self, triggered=self.about)
+ self.aboutAct = QtWidgets.QAction("&About", self, triggered=self.about)
- self.aboutQtAct = QtGui.QAction("About &Qt", self,
- triggered=QtGui.qApp.aboutQt)
+ self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
+ triggered=QtWidgets.qApp.aboutQt)
def createMenus(self):
self.fileMenu = self.menuBar().addMenu("&File")
@@ -146,23 +187,23 @@ class MainWindow(QtGui.QMainWindow):
self.setWindowTitle("%s - Settings Editor" % niceName)
-class LocationDialog(QtGui.QDialog):
+class LocationDialog(QtWidgets.QDialog):
def __init__(self, parent=None):
super(LocationDialog, self).__init__(parent)
- self.formatComboBox = QtGui.QComboBox()
+ self.formatComboBox = QtWidgets.QComboBox()
self.formatComboBox.addItem("Native")
self.formatComboBox.addItem("INI")
- self.scopeComboBox = QtGui.QComboBox()
+ self.scopeComboBox = QtWidgets.QComboBox()
self.scopeComboBox.addItem("User")
self.scopeComboBox.addItem("System")
- self.organizationComboBox = QtGui.QComboBox()
+ self.organizationComboBox = QtWidgets.QComboBox()
self.organizationComboBox.addItem("Trolltech")
self.organizationComboBox.setEditable(True)
- self.applicationComboBox = QtGui.QComboBox()
+ self.applicationComboBox = QtWidgets.QComboBox()
self.applicationComboBox.addItem("Any")
self.applicationComboBox.addItem("Application Example")
self.applicationComboBox.addItem("Assistant")
@@ -171,30 +212,30 @@ class LocationDialog(QtGui.QDialog):
self.applicationComboBox.setEditable(True)
self.applicationComboBox.setCurrentIndex(3)
- formatLabel = QtGui.QLabel("&Format:")
+ formatLabel = QtWidgets.QLabel("&Format:")
formatLabel.setBuddy(self.formatComboBox)
- scopeLabel = QtGui.QLabel("&Scope:")
+ scopeLabel = QtWidgets.QLabel("&Scope:")
scopeLabel.setBuddy(self.scopeComboBox)
- organizationLabel = QtGui.QLabel("&Organization:")
+ organizationLabel = QtWidgets.QLabel("&Organization:")
organizationLabel.setBuddy(self.organizationComboBox)
- applicationLabel = QtGui.QLabel("&Application:")
+ applicationLabel = QtWidgets.QLabel("&Application:")
applicationLabel.setBuddy(self.applicationComboBox)
- self.locationsGroupBox = QtGui.QGroupBox("Setting Locations")
+ self.locationsGroupBox = QtWidgets.QGroupBox("Setting Locations")
- self.locationsTable = QtGui.QTableWidget()
- self.locationsTable.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
- self.locationsTable.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
- self.locationsTable.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
+ self.locationsTable = QtWidgets.QTableWidget()
+ self.locationsTable.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
+ self.locationsTable.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
+ self.locationsTable.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
self.locationsTable.setColumnCount(2)
self.locationsTable.setHorizontalHeaderLabels(("Location", "Access"))
- self.locationsTable.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.Stretch)
+ self.locationsTable.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
self.locationsTable.horizontalHeader().resizeSection(1, 180)
- self.buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
+ self.buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
self.formatComboBox.activated.connect(self.updateLocationsTable)
self.scopeComboBox.activated.connect(self.updateLocationsTable)
@@ -203,11 +244,11 @@ class LocationDialog(QtGui.QDialog):
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
- locationsLayout = QtGui.QVBoxLayout()
+ locationsLayout = QtWidgets.QVBoxLayout()
locationsLayout.addWidget(self.locationsTable)
self.locationsGroupBox.setLayout(locationsLayout)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(formatLabel, 0, 0)
mainLayout.addWidget(self.formatComboBox, 0, 1)
mainLayout.addWidget(scopeLabel, 1, 0)
@@ -274,10 +315,10 @@ class LocationDialog(QtGui.QDialog):
row = self.locationsTable.rowCount()
self.locationsTable.setRowCount(row + 1)
- item0 = QtGui.QTableWidgetItem()
+ item0 = QtWidgets.QTableWidgetItem()
item0.setText(settings.fileName())
- item1 = QtGui.QTableWidgetItem()
+ item1 = QtWidgets.QTableWidgetItem()
disable = not (settings.childKeys() or settings.childGroups())
if row == 0:
@@ -286,7 +327,7 @@ class LocationDialog(QtGui.QDialog):
disable = False
else:
item1.setText("Read-only")
- self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setDisabled(disable)
+ self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setDisabled(disable)
else:
item1.setText("Read-only fallback")
@@ -300,15 +341,15 @@ class LocationDialog(QtGui.QDialog):
self.locationsTable.setUpdatesEnabled(True)
-class SettingsTree(QtGui.QTreeWidget):
+class SettingsTree(QtWidgets.QTreeWidget):
def __init__(self, parent=None):
super(SettingsTree, self).__init__(parent)
self.setItemDelegate(VariantDelegate(self))
self.setHeaderLabels(("Setting", "Type", "Value"))
- self.header().setResizeMode(0, QtGui.QHeaderView.Stretch)
- self.header().setResizeMode(2, QtGui.QHeaderView.Stretch)
+ self.header().setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
+ self.header().setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch)
self.settings = None
self.refreshTimer = QtCore.QTimer()
@@ -316,12 +357,12 @@ class SettingsTree(QtGui.QTreeWidget):
self.autoRefresh = False
self.groupIcon = QtGui.QIcon()
- self.groupIcon.addPixmap(self.style().standardPixmap(QtGui.QStyle.SP_DirClosedIcon),
+ self.groupIcon.addPixmap(self.style().standardPixmap(QtWidgets.QStyle.SP_DirClosedIcon),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
- self.groupIcon.addPixmap(self.style().standardPixmap(QtGui.QStyle.SP_DirOpenIcon),
+ self.groupIcon.addPixmap(self.style().standardPixmap(QtWidgets.QStyle.SP_DirOpenIcon),
QtGui.QIcon.Normal, QtGui.QIcon.On)
self.keyIcon = QtGui.QIcon()
- self.keyIcon.addPixmap(self.style().standardPixmap(QtGui.QStyle.SP_FileIcon))
+ self.keyIcon.addPixmap(self.style().standardPixmap(QtWidgets.QStyle.SP_FileIcon))
self.refreshTimer.timeout.connect(self.maybeRefresh)
@@ -356,7 +397,7 @@ class SettingsTree(QtGui.QTreeWidget):
self.refresh()
def maybeRefresh(self):
- if self.state() != QtGui.QAbstractItemView.EditingState:
+ if self.state() != QtWidgets.QAbstractItemView.EditingState:
self.refresh()
def refresh(self):
@@ -449,9 +490,9 @@ class SettingsTree(QtGui.QTreeWidget):
after = self.childAt(parent, index - 1)
if parent is not None:
- item = QtGui.QTreeWidgetItem(parent, after)
+ item = QtWidgets.QTreeWidgetItem(parent, after)
else:
- item = QtGui.QTreeWidgetItem(self, after)
+ item = QtWidgets.QTreeWidgetItem(self, after)
item.setText(0, text)
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
@@ -487,7 +528,7 @@ class SettingsTree(QtGui.QTreeWidget):
self.deleteItem(parent, newIndex)
-class VariantDelegate(QtGui.QItemDelegate):
+class VariantDelegate(QtWidgets.QItemDelegate):
def __init__(self, parent=None):
super(VariantDelegate, self).__init__(parent)
@@ -534,8 +575,8 @@ class VariantDelegate(QtGui.QItemDelegate):
if index.column() == 2:
value = index.model().data(index, QtCore.Qt.UserRole)
if not self.isSupportedType(value):
- myOption = QtGui.QStyleOptionViewItem(option)
- myOption.state &= ~QtGui.QStyle.State_Enabled
+ myOption = QtWidgets.QStyleOptionViewItem(option)
+ myOption.state &= ~QtWidgets.QStyle.State_Enabled
super(VariantDelegate, self).paint(painter, myOption, index)
return
@@ -549,7 +590,7 @@ class VariantDelegate(QtGui.QItemDelegate):
if not self.isSupportedType(originalValue):
return None
- lineEdit = QtGui.QLineEdit(parent)
+ lineEdit = QtWidgets.QLineEdit(parent)
lineEdit.setFrame(False)
if isinstance(originalValue, bool):
@@ -675,7 +716,7 @@ class VariantDelegate(QtGui.QItemDelegate):
if __name__ == '__main__':
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
sys.exit(app.exec_())
diff --git a/examples/tutorial/t1.py b/examples/tutorial/t1.py
index 26b00c2..b3251db 100755..100644
--- a/examples/tutorial/t1.py
+++ b/examples/tutorial/t1.py
@@ -1,15 +1,55 @@
#!/usr/bin/env python
-# PyQt tutorial 1
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 1
import sys
-from PySide2 import QtGui
+from PySide2 import QtWidgets
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
-hello = QtGui.QPushButton("Hello world!")
+hello = QtWidgets.QPushButton("Hello world!")
hello.resize(100, 30)
hello.show()
diff --git a/examples/tutorial/t10.py b/examples/tutorial/t10.py
index 86fa1ee..081190c 100755..100644
--- a/examples/tutorial/t10.py
+++ b/examples/tutorial/t10.py
@@ -1,18 +1,59 @@
#!/usr/bin/env python
-# PyQt tutorial 10
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 10
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class LCDRange(QtGui.QWidget):
+class LCDRange(QtWidgets.QWidget):
+ valueChanged = QtCore.Signal(int)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- lcd = QtGui.QLCDNumber(2)
- self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ lcd = QtWidgets.QLCDNumber(2)
+ self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
self.slider.setRange(0, 99)
self.slider.setValue(0)
@@ -21,7 +62,7 @@ class LCDRange(QtGui.QWidget):
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
self, QtCore.SIGNAL("valueChanged(int)"))
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(lcd)
layout.addWidget(self.slider)
self.setLayout(layout)
@@ -31,6 +72,7 @@ class LCDRange(QtGui.QWidget):
def value(self):
return self.slider.value()
+ @QtCore.Slot(int)
def setValue(self, value):
self.slider.setValue(value)
@@ -44,9 +86,11 @@ class LCDRange(QtGui.QWidget):
self.slider.setRange(minValue, maxValue)
-class CannonField(QtGui.QWidget):
+class CannonField(QtWidgets.QWidget):
+ angleChanged = QtCore.Signal(int)
+ forceChanged = QtCore.Signal(int)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.currentAngle = 45
self.currentForce = 0
@@ -56,6 +100,7 @@ class CannonField(QtGui.QWidget):
def angle(self):
return self.currentAngle
+ @QtCore.Slot(int)
def setAngle(self, angle):
if angle < 5:
angle = 5
@@ -70,6 +115,7 @@ class CannonField(QtGui.QWidget):
def force(self):
return self.currentForce
+ @QtCore.Slot(int)
def setForce(self, force):
if force < 0:
force = 0
@@ -95,15 +141,15 @@ class CannonField(QtGui.QWidget):
return result
-class MyWidget(QtGui.QWidget):
+class MyWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- quit = QtGui.QPushButton("&Quit")
+ quit = QtWidgets.QPushButton("&Quit")
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
angle = LCDRange()
angle.setRange(5, 70)
@@ -123,11 +169,11 @@ class MyWidget(QtGui.QWidget):
self.connect(cannonField, QtCore.SIGNAL("forceChanged(int)"),
force.setValue)
- leftLayout = QtGui.QVBoxLayout()
+ leftLayout = QtWidgets.QVBoxLayout()
leftLayout.addWidget(angle)
leftLayout.addWidget(force)
- gridLayout = QtGui.QGridLayout()
+ gridLayout = QtWidgets.QGridLayout()
gridLayout.addWidget(quit, 0, 0)
gridLayout.addLayout(leftLayout, 1, 0)
gridLayout.addWidget(cannonField, 1, 1, 2, 1)
@@ -139,7 +185,7 @@ class MyWidget(QtGui.QWidget):
angle.setFocus()
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
widget = MyWidget()
widget.setGeometry(100, 100, 500, 355)
widget.show()
diff --git a/examples/tutorial/t11.py b/examples/tutorial/t11.py
index 9b3da8a..070782b 100755..100644
--- a/examples/tutorial/t11.py
+++ b/examples/tutorial/t11.py
@@ -1,19 +1,60 @@
#!/usr/bin/env python
-# PyQt tutorial 11
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 11
import sys
import math
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class LCDRange(QtGui.QWidget):
+class LCDRange(QtWidgets.QWidget):
+ valueChanged = QtCore.Signal(int)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- lcd = QtGui.QLCDNumber(2)
- self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ lcd = QtWidgets.QLCDNumber(2)
+ self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
self.slider.setRange(0, 99)
self.slider.setValue(0)
@@ -22,7 +63,7 @@ class LCDRange(QtGui.QWidget):
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
self, QtCore.SIGNAL("valueChanged(int)"))
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(lcd)
layout.addWidget(self.slider)
self.setLayout(layout)
@@ -32,6 +73,7 @@ class LCDRange(QtGui.QWidget):
def value(self):
return self.slider.value()
+ @QtCore.Slot(int)
def setValue(self, value):
self.slider.setValue(value)
@@ -45,9 +87,11 @@ class LCDRange(QtGui.QWidget):
self.slider.setRange(minValue, maxValue)
-class CannonField(QtGui.QWidget):
+class CannonField(QtWidgets.QWidget):
+ angleChanged = QtCore.Signal(int)
+ forceChanged = QtCore.Signal(int)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.currentAngle = 45
self.currentForce = 0
@@ -63,6 +107,7 @@ class CannonField(QtGui.QWidget):
def angle(self):
return self.currentAngle
+ @QtCore.Slot(int)
def setAngle(self, angle):
if angle < 5:
angle = 5
@@ -77,6 +122,7 @@ class CannonField(QtGui.QWidget):
def force(self):
return self.currentForce
+ @QtCore.Slot(int)
def setForce(self, force):
if force < 0:
force = 0
@@ -85,6 +131,7 @@ class CannonField(QtGui.QWidget):
self.currentForce = force;
self.emit(QtCore.SIGNAL("forceChanged(int)"), self.currentForce)
+ @QtCore.Slot()
def shoot(self):
if self.autoShootTimer.isActive():
return
@@ -93,6 +140,7 @@ class CannonField(QtGui.QWidget):
self.shootForce = self.currentForce
self.autoShootTimer.start(5)
+ @QtCore.Slot()
def moveShot(self):
region = QtGui.QRegion(self.shotRect())
self.timerCount += 1
@@ -151,19 +199,19 @@ class CannonField(QtGui.QWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
result = QtCore.QRect(0, 0, 6, 6)
- result.moveCenter(QtCore.QPoint(QtCore.qRound(x), self.height() - 1 - QtCore.qRound(y)))
+ result.moveCenter(QtCore.QPoint(round(x), self.height() - 1 - round(y)))
return result
-class MyWidget(QtGui.QWidget):
+class MyWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- quit = QtGui.QPushButton("&Quit")
+ quit = QtWidgets.QPushButton("&Quit")
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
angle = LCDRange()
angle.setRange(5, 70)
@@ -183,20 +231,20 @@ class MyWidget(QtGui.QWidget):
self.connect(cannonField, QtCore.SIGNAL("forceChanged(int)"),
force.setValue)
- shoot = QtGui.QPushButton("&Shoot")
+ shoot = QtWidgets.QPushButton("&Shoot")
shoot.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(shoot, QtCore.SIGNAL("clicked()"), cannonField.shoot)
- topLayout = QtGui.QHBoxLayout()
+ topLayout = QtWidgets.QHBoxLayout()
topLayout.addWidget(shoot)
topLayout.addStretch(1)
- leftLayout = QtGui.QVBoxLayout()
+ leftLayout = QtWidgets.QVBoxLayout()
leftLayout.addWidget(angle)
leftLayout.addWidget(force)
- gridLayout = QtGui.QGridLayout()
+ gridLayout = QtWidgets.QGridLayout()
gridLayout.addWidget(quit, 0, 0)
gridLayout.addLayout(topLayout, 0, 1)
gridLayout.addLayout(leftLayout, 1, 0)
@@ -209,7 +257,7 @@ class MyWidget(QtGui.QWidget):
angle.setFocus()
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
widget = MyWidget()
widget.setGeometry(100, 100, 500, 355)
widget.show()
diff --git a/examples/tutorial/t12.py b/examples/tutorial/t12.py
index 1be4b3b..6afd880 100755..100644
--- a/examples/tutorial/t12.py
+++ b/examples/tutorial/t12.py
@@ -1,21 +1,62 @@
#!/usr/bin/env python
-# PyQt tutorial 12
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 12
import sys
import math
import random
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class LCDRange(QtGui.QWidget):
+class LCDRange(QtWidgets.QWidget):
+ valueChanged = QtCore.Signal(int)
def __init__(self, text=None, parent=None):
- if isinstance(text, QtGui.QWidget):
+ if isinstance(text, QtWidgets.QWidget):
parent = text
text = None
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.init()
@@ -23,11 +64,11 @@ class LCDRange(QtGui.QWidget):
self.setText(text)
def init(self):
- lcd = QtGui.QLCDNumber(2)
- self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ lcd = QtWidgets.QLCDNumber(2)
+ self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
self.slider.setRange(0, 99)
self.slider.setValue(0)
- self.label = QtGui.QLabel()
+ self.label = QtWidgets.QLabel()
self.label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop)
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
@@ -35,7 +76,7 @@ class LCDRange(QtGui.QWidget):
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
self, QtCore.SIGNAL("valueChanged(int)"))
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(lcd)
layout.addWidget(self.slider)
layout.addWidget(self.label)
@@ -46,6 +87,7 @@ class LCDRange(QtGui.QWidget):
def value(self):
return self.slider.value()
+ @QtCore.Slot(int)
def setValue(self, value):
self.slider.setValue(value)
@@ -65,9 +107,11 @@ class LCDRange(QtGui.QWidget):
self.label.setText(text)
-class CannonField(QtGui.QWidget):
+class CannonField(QtWidgets.QWidget):
+ angleChanged = QtCore.Signal(int)
+ forceChanged = QtCore.Signal(int)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.currentAngle = 45
self.currentForce = 0
@@ -85,6 +129,7 @@ class CannonField(QtGui.QWidget):
def angle(self):
return self.currentAngle
+ @QtCore.Slot(int)
def setAngle(self, angle):
if angle < 5:
angle = 5
@@ -99,6 +144,7 @@ class CannonField(QtGui.QWidget):
def force(self):
return self.currentForce
+ @QtCore.Slot(int)
def setForce(self, force):
if force < 0:
force = 0
@@ -107,6 +153,7 @@ class CannonField(QtGui.QWidget):
self.currentForce = force;
self.emit(QtCore.SIGNAL("forceChanged(int)"), self.currentForce)
+ @QtCore.Slot()
def shoot(self):
if self.autoShootTimer.isActive():
return
@@ -126,6 +173,7 @@ class CannonField(QtGui.QWidget):
self.target = QtCore.QPoint(200 + random.randint(0, 190 - 1), 10 + random.randint(0, 255 - 1))
self.update()
+ @QtCore.Slot()
def moveShot(self):
region = QtGui.QRegion(self.shotRect())
self.timerCount += 1
@@ -195,7 +243,7 @@ class CannonField(QtGui.QWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
result = QtCore.QRect(0, 0, 6, 6)
- result.moveCenter(QtCore.QPoint(QtCore.qRound(x), self.height() - 1 - QtCore.qRound(y)))
+ result.moveCenter(QtCore.QPoint(round(x), self.height() - 1 - round(y)))
return result
def targetRect(self):
@@ -204,15 +252,15 @@ class CannonField(QtGui.QWidget):
return result
-class MyWidget(QtGui.QWidget):
+class MyWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- quit = QtGui.QPushButton("&Quit")
+ quit = QtWidgets.QPushButton("&Quit")
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
angle = LCDRange("ANGLE")
angle.setRange(5, 70)
@@ -232,20 +280,20 @@ class MyWidget(QtGui.QWidget):
self.connect(cannonField, QtCore.SIGNAL("forceChanged(int)"),
force.setValue)
- shoot = QtGui.QPushButton("&Shoot")
+ shoot = QtWidgets.QPushButton("&Shoot")
shoot.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(shoot, QtCore.SIGNAL("clicked()"), cannonField.shoot)
- topLayout = QtGui.QHBoxLayout()
+ topLayout = QtWidgets.QHBoxLayout()
topLayout.addWidget(shoot)
topLayout.addStretch(1)
- leftLayout = QtGui.QVBoxLayout()
+ leftLayout = QtWidgets.QVBoxLayout()
leftLayout.addWidget(angle)
leftLayout.addWidget(force)
- gridLayout = QtGui.QGridLayout()
+ gridLayout = QtWidgets.QGridLayout()
gridLayout.addWidget(quit, 0, 0)
gridLayout.addLayout(topLayout, 0, 1)
gridLayout.addLayout(leftLayout, 1, 0)
@@ -258,7 +306,7 @@ class MyWidget(QtGui.QWidget):
angle.setFocus()
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
widget = MyWidget()
widget.setGeometry(100, 100, 500, 355)
widget.show()
diff --git a/examples/tutorial/t13.py b/examples/tutorial/t13.py
index 41829a4..34f2fe5 100755..100644
--- a/examples/tutorial/t13.py
+++ b/examples/tutorial/t13.py
@@ -1,21 +1,62 @@
#!/usr/bin/env python
-# PyQt tutorial 13
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 13
import sys
import math
import random
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class LCDRange(QtGui.QWidget):
+class LCDRange(QtWidgets.QWidget):
+ valueChanged = QtCore.Signal(int)
def __init__(self, text=None, parent=None):
- if isinstance(text, QtGui.QWidget):
+ if isinstance(text, QtWidgets.QWidget):
parent = text
text = None
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.init()
@@ -23,20 +64,20 @@ class LCDRange(QtGui.QWidget):
self.setText(text)
def init(self):
- lcd = QtGui.QLCDNumber(2)
- self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ lcd = QtWidgets.QLCDNumber(2)
+ self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
self.slider.setRange(0, 99)
self.slider.setValue(0)
- self.label = QtGui.QLabel()
+ self.label = QtWidgets.QLabel()
self.label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop)
- self.label.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
+ self.label.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
lcd, QtCore.SLOT("display(int)"))
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
self, QtCore.SIGNAL("valueChanged(int)"))
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(lcd)
layout.addWidget(self.slider)
layout.addWidget(self.label)
@@ -47,6 +88,7 @@ class LCDRange(QtGui.QWidget):
def value(self):
return self.slider.value()
+ @QtCore.Slot(int)
def setValue(self, value):
self.slider.setValue(value)
@@ -66,9 +108,14 @@ class LCDRange(QtGui.QWidget):
self.label.setText(text)
-class CannonField(QtGui.QWidget):
+class CannonField(QtWidgets.QWidget):
+ angleChanged = QtCore.Signal(int)
+ forceChanged = QtCore.Signal(int)
+ hit = QtCore.Signal()
+ missed = QtCore.Signal()
+ canShoot = QtCore.Signal(bool)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.currentAngle = 45
self.currentForce = 0
@@ -87,6 +134,7 @@ class CannonField(QtGui.QWidget):
def angle(self):
return self.currentAngle
+ @QtCore.Slot(int)
def setAngle(self, angle):
if angle < 5:
angle = 5
@@ -101,6 +149,7 @@ class CannonField(QtGui.QWidget):
def force(self):
return self.currentForce
+ @QtCore.Slot(int)
def setForce(self, force):
if force < 0:
force = 0
@@ -109,6 +158,7 @@ class CannonField(QtGui.QWidget):
self.currentForce = force;
self.emit(QtCore.SIGNAL("forceChanged(int)"), self.currentForce)
+ @QtCore.Slot()
def shoot(self):
if self.isShooting():
return
@@ -144,6 +194,7 @@ class CannonField(QtGui.QWidget):
self.update()
self.emit(QtCore.SIGNAL("canShoot(bool)"), True)
+ @QtCore.Slot()
def moveShot(self):
region = QtGui.QRegion(self.shotRect())
self.timerCount += 1
@@ -220,7 +271,7 @@ class CannonField(QtGui.QWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
result = QtCore.QRect(0, 0, 6, 6)
- result.moveCenter(QtCore.QPoint(QtCore.qRound(x), self.height() - 1 - QtCore.qRound(y)))
+ result.moveCenter(QtCore.QPoint(round(x), self.height() - 1 - round(y)))
return result
def targetRect(self):
@@ -235,15 +286,15 @@ class CannonField(QtGui.QWidget):
return self.autoShootTimer.isActive()
-class GameBoard(QtGui.QWidget):
+class GameBoard(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- quit = QtGui.QPushButton("&Quit")
+ quit = QtWidgets.QPushButton("&Quit")
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
angle = LCDRange("ANGLE")
angle.setRange(5, 70)
@@ -266,24 +317,24 @@ class GameBoard(QtGui.QWidget):
self.connect(self.cannonField, QtCore.SIGNAL("hit()"), self.hit)
self.connect(self.cannonField, QtCore.SIGNAL("missed()"), self.missed)
- shoot = QtGui.QPushButton("&Shoot")
+ shoot = QtWidgets.QPushButton("&Shoot")
shoot.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(shoot, QtCore.SIGNAL("clicked()"), self.fire)
self.connect(self.cannonField, QtCore.SIGNAL("canShoot(bool)"),
shoot, QtCore.SLOT("setEnabled(bool)"))
- restart = QtGui.QPushButton("&New Game")
+ restart = QtWidgets.QPushButton("&New Game")
restart.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(restart, QtCore.SIGNAL("clicked()"), self.newGame)
- self.hits = QtGui.QLCDNumber(2)
- self.shotsLeft = QtGui.QLCDNumber(2)
- hitsLabel = QtGui.QLabel("HITS")
- shotsLeftLabel = QtGui.QLabel("SHOTS LEFT")
+ self.hits = QtWidgets.QLCDNumber(2)
+ self.shotsLeft = QtWidgets.QLCDNumber(2)
+ hitsLabel = QtWidgets.QLabel("HITS")
+ shotsLeftLabel = QtWidgets.QLabel("SHOTS LEFT")
- topLayout = QtGui.QHBoxLayout()
+ topLayout = QtWidgets.QHBoxLayout()
topLayout.addWidget(shoot)
topLayout.addWidget(self.hits)
topLayout.addWidget(hitsLabel)
@@ -292,11 +343,11 @@ class GameBoard(QtGui.QWidget):
topLayout.addStretch(1)
topLayout.addWidget(restart)
- leftLayout = QtGui.QVBoxLayout()
+ leftLayout = QtWidgets.QVBoxLayout()
leftLayout.addWidget(angle)
leftLayout.addWidget(force)
- gridLayout = QtGui.QGridLayout()
+ gridLayout = QtWidgets.QGridLayout()
gridLayout.addWidget(quit, 0, 0)
gridLayout.addLayout(topLayout, 0, 1)
gridLayout.addLayout(leftLayout, 1, 0)
@@ -310,12 +361,14 @@ class GameBoard(QtGui.QWidget):
self.newGame()
+ @QtCore.Slot()
def fire(self):
if self.cannonField.gameOver() or self.cannonField.isShooting():
return
self.shotsLeft.display(self.shotsLeft.intValue() - 1)
self.cannonField.shoot()
+ @QtCore.Slot()
def hit(self):
self.hits.display(self.hits.intValue() + 1)
if self.shotsLeft.intValue() == 0:
@@ -323,10 +376,12 @@ class GameBoard(QtGui.QWidget):
else:
self.cannonField.newTarget()
+ @QtCore.Slot()
def missed(self):
if self.shotsLeft.intValue() == 0:
self.cannonField.setGameOver()
+ @QtCore.Slot()
def newGame(self):
self.shotsLeft.display(15)
self.hits.display(0)
@@ -334,7 +389,7 @@ class GameBoard(QtGui.QWidget):
self.cannonField.newTarget()
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
board = GameBoard()
board.setGeometry(100, 100, 500, 355)
board.show()
diff --git a/examples/tutorial/t14.py b/examples/tutorial/t14.py
index e9287fd..609af40 100755..100644
--- a/examples/tutorial/t14.py
+++ b/examples/tutorial/t14.py
@@ -1,21 +1,62 @@
#!/usr/bin/env python
-# PyQt tutorial 14
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 14
import sys
import math
import random
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class LCDRange(QtGui.QWidget):
+class LCDRange(QtWidgets.QWidget):
+ valueChanged = QtCore.Signal(int)
def __init__(self, text=None, parent=None):
- if isinstance(text, QtGui.QWidget):
+ if isinstance(text, QtWidgets.QWidget):
parent = text
text = None
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.init()
@@ -23,20 +64,20 @@ class LCDRange(QtGui.QWidget):
self.setText(text)
def init(self):
- lcd = QtGui.QLCDNumber(2)
- self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ lcd = QtWidgets.QLCDNumber(2)
+ self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
self.slider.setRange(0, 99)
self.slider.setValue(0)
- self.label = QtGui.QLabel()
+ self.label = QtWidgets.QLabel()
self.label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop)
- self.label.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
+ self.label.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
lcd, QtCore.SLOT("display(int)"))
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
self, QtCore.SIGNAL("valueChanged(int)"))
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(lcd)
layout.addWidget(self.slider)
layout.addWidget(self.label)
@@ -47,6 +88,7 @@ class LCDRange(QtGui.QWidget):
def value(self):
return self.slider.value()
+ @QtCore.Slot(int)
def setValue(self, value):
self.slider.setValue(value)
@@ -66,9 +108,14 @@ class LCDRange(QtGui.QWidget):
self.label.setText(text)
-class CannonField(QtGui.QWidget):
+class CannonField(QtWidgets.QWidget):
+ angleChanged = QtCore.Signal(int)
+ forceChanged = QtCore.Signal(int)
+ hit = QtCore.Signal()
+ missed = QtCore.Signal()
+ canShoot = QtCore.Signal(bool)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.currentAngle = 45
self.currentForce = 0
@@ -88,6 +135,7 @@ class CannonField(QtGui.QWidget):
def angle(self):
return self.currentAngle
+ @QtCore.Slot(int)
def setAngle(self, angle):
if angle < 5:
angle = 5
@@ -102,6 +150,7 @@ class CannonField(QtGui.QWidget):
def force(self):
return self.currentForce
+ @QtCore.Slot(int)
def setForce(self, force):
if force < 0:
force = 0
@@ -110,6 +159,7 @@ class CannonField(QtGui.QWidget):
self.currentForce = force;
self.emit(QtCore.SIGNAL("forceChanged(int)"), self.currentForce)
+ @QtCore.Slot()
def shoot(self):
if self.isShooting():
return
@@ -145,6 +195,7 @@ class CannonField(QtGui.QWidget):
self.update()
self.emit(QtCore.SIGNAL("canShoot(bool)"), True)
+ @QtCore.Slot()
def moveShot(self):
region = QtGui.QRegion(self.shotRect())
self.timerCount += 1
@@ -179,7 +230,7 @@ class CannonField(QtGui.QWidget):
if pos.y() >= self.height():
pos.setY(self.height() - 1)
rad = math.atan((float(self.rect().bottom()) - pos.y()) / pos.x())
- self.setAngle(QtCore.qRound(rad * 180 / 3.14159265))
+ self.setAngle(round(rad * 180 / 3.14159265))
def mouseReleaseEvent(self, event):
if event.button() == QtCore.Qt.LeftButton:
@@ -248,7 +299,7 @@ class CannonField(QtGui.QWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
result = QtCore.QRect(0, 0, 6, 6)
- result.moveCenter(QtCore.QPoint(QtCore.qRound(x), self.height() - 1 - QtCore.qRound(y)))
+ result.moveCenter(QtCore.QPoint(round(x), self.height() - 1 - round(y)))
return result
def targetRect(self):
@@ -276,15 +327,15 @@ class CannonField(QtGui.QWidget):
return QtCore.QSize(400, 300)
-class GameBoard(QtGui.QWidget):
+class GameBoard(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- quit = QtGui.QPushButton("&Quit")
+ quit = QtWidgets.QPushButton("&Quit")
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
angle = LCDRange("ANGLE")
angle.setRange(5, 70)
@@ -292,8 +343,8 @@ class GameBoard(QtGui.QWidget):
force = LCDRange("FORCE")
force.setRange(10, 50)
- cannonBox = QtGui.QFrame()
- cannonBox.setFrameStyle(QtGui.QFrame.WinPanel | QtGui.QFrame.Sunken)
+ cannonBox = QtWidgets.QFrame()
+ cannonBox.setFrameStyle(QtWidgets.QFrame.WinPanel | QtWidgets.QFrame.Sunken)
self.cannonField = CannonField()
@@ -310,31 +361,31 @@ class GameBoard(QtGui.QWidget):
self.connect(self.cannonField, QtCore.SIGNAL("hit()"), self.hit)
self.connect(self.cannonField, QtCore.SIGNAL("missed()"), self.missed)
- shoot = QtGui.QPushButton("&Shoot")
+ shoot = QtWidgets.QPushButton("&Shoot")
shoot.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(shoot, QtCore.SIGNAL("clicked()"), self.fire)
self.connect(self.cannonField, QtCore.SIGNAL("canShoot(bool)"),
shoot, QtCore.SLOT("setEnabled(bool)"))
- restart = QtGui.QPushButton("&New Game")
+ restart = QtWidgets.QPushButton("&New Game")
restart.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(restart, QtCore.SIGNAL("clicked()"), self.newGame)
- self.hits = QtGui.QLCDNumber(2)
- self.shotsLeft = QtGui.QLCDNumber(2)
- hitsLabel = QtGui.QLabel("HITS")
- shotsLeftLabel = QtGui.QLabel("SHOTS LEFT")
+ self.hits = QtWidgets.QLCDNumber(2)
+ self.shotsLeft = QtWidgets.QLCDNumber(2)
+ hitsLabel = QtWidgets.QLabel("HITS")
+ shotsLeftLabel = QtWidgets.QLabel("SHOTS LEFT")
- QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Enter),
+ QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Enter),
self, self.fire)
- QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Return),
+ QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Return),
self, self.fire)
- QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Q),
+ QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Q),
self, QtCore.SLOT("close()"))
- topLayout = QtGui.QHBoxLayout()
+ topLayout = QtWidgets.QHBoxLayout()
topLayout.addWidget(shoot)
topLayout.addWidget(self.hits)
topLayout.addWidget(hitsLabel)
@@ -343,15 +394,15 @@ class GameBoard(QtGui.QWidget):
topLayout.addStretch(1)
topLayout.addWidget(restart)
- leftLayout = QtGui.QVBoxLayout()
+ leftLayout = QtWidgets.QVBoxLayout()
leftLayout.addWidget(angle)
leftLayout.addWidget(force)
- cannonLayout = QtGui.QVBoxLayout()
+ cannonLayout = QtWidgets.QVBoxLayout()
cannonLayout.addWidget(self.cannonField)
cannonBox.setLayout(cannonLayout)
- gridLayout = QtGui.QGridLayout()
+ gridLayout = QtWidgets.QGridLayout()
gridLayout.addWidget(quit, 0, 0)
gridLayout.addLayout(topLayout, 0, 1)
gridLayout.addLayout(leftLayout, 1, 0)
@@ -365,12 +416,14 @@ class GameBoard(QtGui.QWidget):
self.newGame()
+ @QtCore.Slot()
def fire(self):
if self.cannonField.gameOver() or self.cannonField.isShooting():
return
self.shotsLeft.display(self.shotsLeft.intValue() - 1)
self.cannonField.shoot()
+ @QtCore.Slot()
def hit(self):
self.hits.display(self.hits.intValue() + 1)
if self.shotsLeft.intValue() == 0:
@@ -378,10 +431,12 @@ class GameBoard(QtGui.QWidget):
else:
self.cannonField.newTarget()
+ @QtCore.Slot()
def missed(self):
if self.shotsLeft.intValue() == 0:
self.cannonField.setGameOver()
+ @QtCore.Slot()
def newGame(self):
self.shotsLeft.display(15)
self.hits.display(0)
@@ -389,7 +444,7 @@ class GameBoard(QtGui.QWidget):
self.cannonField.newTarget()
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
board = GameBoard()
board.setGeometry(100, 100, 500, 355)
board.show()
diff --git a/examples/tutorial/t2.py b/examples/tutorial/t2.py
index d670157..91ca2f3 100755..100644
--- a/examples/tutorial/t2.py
+++ b/examples/tutorial/t2.py
@@ -1,15 +1,55 @@
#!/usr/bin/env python
-# PyQt tutorial 2
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 2
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
-quit = QtGui.QPushButton("Quit")
+quit = QtWidgets.QPushButton("Quit")
quit.resize(75, 30)
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
diff --git a/examples/tutorial/t3.py b/examples/tutorial/t3.py
index a0f7339..9dc50a1 100755..100644
--- a/examples/tutorial/t3.py
+++ b/examples/tutorial/t3.py
@@ -1,18 +1,58 @@
#!/usr/bin/env python
-# PyQt tutorial 3
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 3
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
-window = QtGui.QWidget()
+window = QtWidgets.QWidget()
window.resize(200, 120)
-quit = QtGui.QPushButton("Quit", window)
+quit = QtWidgets.QPushButton("Quit", window)
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
quit.setGeometry(10, 40, 180, 40)
QtCore.QObject.connect(quit, QtCore.SIGNAL("clicked()"),
diff --git a/examples/tutorial/t4.py b/examples/tutorial/t4.py
index 0f6fc5d..77f593d 100755..100644
--- a/examples/tutorial/t4.py
+++ b/examples/tutorial/t4.py
@@ -1,27 +1,67 @@
#!/usr/bin/env python
-# PyQt tutorial 4
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 4
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class MyWidget(QtGui.QWidget):
+class MyWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.setFixedSize(200, 120)
- self.quit = QtGui.QPushButton("Quit", self)
+ self.quit = QtWidgets.QPushButton("Quit", self)
self.quit.setGeometry(62, 40, 75, 30)
self.quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(self.quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
widget = MyWidget()
widget.show()
sys.exit(app.exec_())
diff --git a/examples/tutorial/t5.py b/examples/tutorial/t5.py
index 237c254..0fdd2ac 100755..100644
--- a/examples/tutorial/t5.py
+++ b/examples/tutorial/t5.py
@@ -1,38 +1,78 @@
#!/usr/bin/env python
-# PyQt tutorial 5
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 5
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class MyWidget(QtGui.QWidget):
+class MyWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- quit = QtGui.QPushButton("Quit")
+ quit = QtWidgets.QPushButton("Quit")
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
- lcd = QtGui.QLCDNumber(2)
+ lcd = QtWidgets.QLCDNumber(2)
- slider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
slider.setRange(0, 99)
slider.setValue(0)
self.connect(quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
self.connect(slider, QtCore.SIGNAL("valueChanged(int)"),
lcd, QtCore.SLOT("display(int)"))
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(quit);
layout.addWidget(lcd);
layout.addWidget(slider);
self.setLayout(layout);
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
widget = MyWidget()
widget.show()
sys.exit(app.exec_())
diff --git a/examples/tutorial/t6.py b/examples/tutorial/t6.py
index 8636aba..d720433 100755..100644
--- a/examples/tutorial/t6.py
+++ b/examples/tutorial/t6.py
@@ -1,40 +1,80 @@
#!/usr/bin/env python
-# PyQt tutorial 6
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 6
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class LCDRange(QtGui.QWidget):
+class LCDRange(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- lcd = QtGui.QLCDNumber(2)
- slider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ lcd = QtWidgets.QLCDNumber(2)
+ slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
slider.setRange(0, 99)
slider.setValue(0)
self.connect(slider, QtCore.SIGNAL("valueChanged(int)"),
lcd, QtCore.SLOT("display(int)"))
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(lcd)
layout.addWidget(slider)
self.setLayout(layout)
-class MyWidget(QtGui.QWidget):
+class MyWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- quit = QtGui.QPushButton("Quit")
+ quit = QtWidgets.QPushButton("Quit")
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
- grid = QtGui.QGridLayout()
- layout = QtGui.QVBoxLayout()
+ grid = QtWidgets.QGridLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(quit)
layout.addLayout(grid)
self.setLayout(layout)
@@ -45,7 +85,7 @@ class MyWidget(QtGui.QWidget):
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
widget = MyWidget()
widget.show()
sys.exit(app.exec_())
diff --git a/examples/tutorial/t7.py b/examples/tutorial/t7.py
index b981ee9..a9c53f6 100755..100644
--- a/examples/tutorial/t7.py
+++ b/examples/tutorial/t7.py
@@ -1,19 +1,60 @@
#!/usr/bin/env python
-# PyQt tutorial 7
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 7
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class LCDRange(QtGui.QWidget):
+class LCDRange(QtWidgets.QWidget):
+ valueChanged = QtCore.Signal(int)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- lcd = QtGui.QLCDNumber(2)
+ lcd = QtWidgets.QLCDNumber(2)
- self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
self.slider.setRange(0, 99)
self.slider.setValue(0)
@@ -22,7 +63,7 @@ class LCDRange(QtGui.QWidget):
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
self, QtCore.SIGNAL("valueChanged(int)"))
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(lcd)
layout.addWidget(self.slider)
self.setLayout(layout)
@@ -30,25 +71,26 @@ class LCDRange(QtGui.QWidget):
def value(self):
return self.slider.value()
+ @QtCore.Slot(int)
def setValue(self, value):
self.slider.setValue(value)
-class MyWidget(QtGui.QWidget):
+class MyWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- quit = QtGui.QPushButton("Quit")
+ quit = QtWidgets.QPushButton("Quit")
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
- grid = QtGui.QGridLayout()
+ grid = QtWidgets.QGridLayout()
previousRange = None
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(quit)
layout.addLayout(grid)
self.setLayout(layout)
@@ -66,7 +108,7 @@ class MyWidget(QtGui.QWidget):
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
widget = MyWidget()
widget.show()
sys.exit(app.exec_())
diff --git a/examples/tutorial/t8.py b/examples/tutorial/t8.py
index 697de9a..d023de1 100755..100644
--- a/examples/tutorial/t8.py
+++ b/examples/tutorial/t8.py
@@ -1,18 +1,59 @@
#!/usr/bin/env python
-# PyQt tutorial 8
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 8
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class LCDRange(QtGui.QWidget):
+class LCDRange(QtWidgets.QWidget):
+ valueChanged = QtCore.Signal(int)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- lcd = QtGui.QLCDNumber(2)
- self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ lcd = QtWidgets.QLCDNumber(2)
+ self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
self.slider.setRange(0, 99)
self.slider.setValue(0)
@@ -21,7 +62,7 @@ class LCDRange(QtGui.QWidget):
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
self, QtCore.SIGNAL("valueChanged(int)"))
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(lcd)
layout.addWidget(self.slider)
self.setLayout(layout)
@@ -31,6 +72,7 @@ class LCDRange(QtGui.QWidget):
def value(self):
return self.slider.value()
+ @QtCore.Slot(int)
def setValue(self, value):
self.slider.setValue(value)
@@ -44,9 +86,10 @@ class LCDRange(QtGui.QWidget):
self.slider.setRange(minValue, maxValue)
-class CannonField(QtGui.QWidget):
+class CannonField(QtWidgets.QWidget):
+ angleChanged = QtCore.Signal(int)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.currentAngle = 45
self.setPalette(QtGui.QPalette(QtGui.QColor(250, 250, 200)))
@@ -55,6 +98,7 @@ class CannonField(QtGui.QWidget):
def angle(self):
return self.currentAngle
+ @QtCore.Slot(int)
def setAngle(self, angle):
if angle < 5:
angle = 5
@@ -71,15 +115,15 @@ class CannonField(QtGui.QWidget):
painter.drawText(200, 200, "Angle = %d" % self.currentAngle)
-class MyWidget(QtGui.QWidget):
+class MyWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- quit = QtGui.QPushButton("Quit")
+ quit = QtWidgets.QPushButton("Quit")
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
angle = LCDRange()
angle.setRange(5, 70)
@@ -91,7 +135,7 @@ class MyWidget(QtGui.QWidget):
self.connect(cannonField, QtCore.SIGNAL("angleChanged(int)"),
angle.setValue)
- gridLayout = QtGui.QGridLayout()
+ gridLayout = QtWidgets.QGridLayout()
gridLayout.addWidget(quit, 0, 0)
gridLayout.addWidget(angle, 1, 0)
gridLayout.addWidget(cannonField, 1, 1, 2, 1)
@@ -102,7 +146,7 @@ class MyWidget(QtGui.QWidget):
angle.setFocus()
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
widget = MyWidget()
widget.setGeometry(100, 100, 500, 355)
widget.show()
diff --git a/examples/tutorial/t9.py b/examples/tutorial/t9.py
index 0a6bd59..37c0e65 100755..100644
--- a/examples/tutorial/t9.py
+++ b/examples/tutorial/t9.py
@@ -1,18 +1,59 @@
#!/usr/bin/env python
-# PyQt tutorial 9
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+# PySide2 tutorial 9
import sys
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class LCDRange(QtGui.QWidget):
+class LCDRange(QtWidgets.QWidget):
+ valueChanged = QtCore.Signal(int)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- lcd = QtGui.QLCDNumber(2)
- self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
+ lcd = QtWidgets.QLCDNumber(2)
+ self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
self.slider.setRange(0, 99)
self.slider.setValue(0)
@@ -21,7 +62,7 @@ class LCDRange(QtGui.QWidget):
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
self, QtCore.SIGNAL("valueChanged(int)"))
- layout = QtGui.QVBoxLayout()
+ layout = QtWidgets.QVBoxLayout()
layout.addWidget(lcd)
layout.addWidget(self.slider)
self.setLayout(layout)
@@ -31,6 +72,7 @@ class LCDRange(QtGui.QWidget):
def value(self):
return self.slider.value()
+ @QtCore.Slot(int)
def setValue(self, value):
self.slider.setValue(value)
@@ -44,9 +86,10 @@ class LCDRange(QtGui.QWidget):
self.slider.setRange(minValue, maxValue)
-class CannonField(QtGui.QWidget):
+class CannonField(QtWidgets.QWidget):
+ angleChanged = QtCore.Signal(int)
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
self.currentAngle = 45
self.setPalette(QtGui.QPalette(QtGui.QColor(250, 250, 200)))
@@ -55,6 +98,7 @@ class CannonField(QtGui.QWidget):
def angle(self):
return self.currentAngle
+ @QtCore.Slot(int)
def setAngle(self, angle):
if angle < 5:
angle = 5
@@ -78,15 +122,15 @@ class CannonField(QtGui.QWidget):
painter.drawRect(QtCore.QRect(33, -4, 15, 8))
-class MyWidget(QtGui.QWidget):
+class MyWidget(QtWidgets.QWidget):
def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ QtWidgets.QWidget.__init__(self, parent)
- quit = QtGui.QPushButton("Quit")
+ quit = QtWidgets.QPushButton("Quit")
quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
+ QtWidgets.qApp, QtCore.SLOT("quit()"))
angle = LCDRange()
angle.setRange(5, 70)
@@ -98,7 +142,7 @@ class MyWidget(QtGui.QWidget):
self.connect(cannonField, QtCore.SIGNAL("angleChanged(int)"),
angle.setValue)
- gridLayout = QtGui.QGridLayout()
+ gridLayout = QtWidgets.QGridLayout()
gridLayout.addWidget(quit, 0, 0)
gridLayout.addWidget(angle, 1, 0)
gridLayout.addWidget(cannonField, 1, 1, 2, 1)
@@ -109,7 +153,7 @@ class MyWidget(QtGui.QWidget):
angle.setFocus()
-app = QtGui.QApplication(sys.argv)
+app = QtWidgets.QApplication(sys.argv)
widget = MyWidget()
widget.setGeometry(100, 100, 500, 355)
widget.show()
diff --git a/examples/tutorials/addressbook/part1.py b/examples/tutorials/addressbook/part1.py
index 7bf7a6e..c14aab9 100755
--- a/examples/tutorials/addressbook/part1.py
+++ b/examples/tutorials/addressbook/part1.py
@@ -2,27 +2,59 @@
#############################################################################
##
-## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-## Contact: Qt Software Information (qt-info@nokia.com)
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
-class AddressBook(QtGui.QWidget):
+class AddressBook(QtWidgets.QWidget):
def __init__(self, parent=None):
super(AddressBook, self).__init__(parent)
- nameLabel = QtGui.QLabel("Name:")
- self.nameLine = QtGui.QLineEdit()
+ nameLabel = QtWidgets.QLabel("Name:")
+ self.nameLine = QtWidgets.QLineEdit()
- addressLabel = QtGui.QLabel("Address:")
- self.addressText = QtGui.QTextEdit()
+ addressLabel = QtWidgets.QLabel("Address:")
+ self.addressText = QtWidgets.QTextEdit()
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, QtCore.Qt.AlignTop)
@@ -35,7 +67,7 @@ class AddressBook(QtGui.QWidget):
if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
addressBook = AddressBook()
addressBook.show()
diff --git a/examples/tutorials/addressbook/part2.py b/examples/tutorials/addressbook/part2.py
index 5d9b453..62fe157 100755
--- a/examples/tutorials/addressbook/part2.py
+++ b/examples/tutorials/addressbook/part2.py
@@ -2,14 +2,46 @@
#############################################################################
##
-## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-## Contact: Qt Software Information (qt-info@nokia.com)
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
class SortedDict(dict):
@@ -41,7 +73,7 @@ class SortedDict(dict):
iterkeys = __iter__
-class AddressBook(QtGui.QWidget):
+class AddressBook(QtWidgets.QWidget):
def __init__(self, parent=None):
super(AddressBook, self).__init__(parent)
@@ -49,32 +81,32 @@ class AddressBook(QtGui.QWidget):
self.oldName = ''
self.oldAddress = ''
- nameLabel = QtGui.QLabel("Name:")
- self.nameLine = QtGui.QLineEdit()
+ nameLabel = QtWidgets.QLabel("Name:")
+ self.nameLine = QtWidgets.QLineEdit()
self.nameLine.setReadOnly(True)
- addressLabel = QtGui.QLabel("Address:")
- self.addressText = QtGui.QTextEdit()
+ addressLabel = QtWidgets.QLabel("Address:")
+ self.addressText = QtWidgets.QTextEdit()
self.addressText.setReadOnly(True)
- self.addButton = QtGui.QPushButton("&Add")
+ self.addButton = QtWidgets.QPushButton("&Add")
self.addButton.show()
- self.submitButton = QtGui.QPushButton("&Submit")
+ self.submitButton = QtWidgets.QPushButton("&Submit")
self.submitButton.hide()
- self.cancelButton = QtGui.QPushButton("&Cancel")
+ self.cancelButton = QtWidgets.QPushButton("&Cancel")
self.cancelButton.hide()
self.addButton.clicked.connect(self.addContact)
self.submitButton.clicked.connect(self.submitContact)
self.cancelButton.clicked.connect(self.cancel)
- buttonLayout1 = QtGui.QVBoxLayout()
+ buttonLayout1 = QtWidgets.QVBoxLayout()
buttonLayout1.addWidget(self.addButton, QtCore.Qt.AlignTop)
buttonLayout1.addWidget(self.submitButton)
buttonLayout1.addWidget(self.cancelButton)
buttonLayout1.addStretch()
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, QtCore.Qt.AlignTop)
@@ -104,16 +136,16 @@ class AddressBook(QtGui.QWidget):
address = self.addressText.toPlainText()
if name == "" or address == "":
- QtGui.QMessageBox.information(self, "Empty Field",
+ QtWidgets.QMessageBox.information(self, "Empty Field",
"Please enter a name and address.")
return
if name not in self.contacts:
self.contacts[name] = address
- QtGui.QMessageBox.information(self, "Add Successful",
+ QtWidgets.QMessageBox.information(self, "Add Successful",
"\"%s\" has been added to your address book." % name)
else:
- QtGui.QMessageBox.information(self, "Add Unsuccessful",
+ QtWidgets.QMessageBox.information(self, "Add Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
@@ -142,7 +174,7 @@ class AddressBook(QtGui.QWidget):
if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
addressBook = AddressBook()
addressBook.show()
diff --git a/examples/tutorials/addressbook/part3.py b/examples/tutorials/addressbook/part3.py
index 766dacf..8db6e6a 100755
--- a/examples/tutorials/addressbook/part3.py
+++ b/examples/tutorials/addressbook/part3.py
@@ -2,14 +2,46 @@
#############################################################################
##
-## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-## Contact: Qt Software Information (qt-info@nokia.com)
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
class SortedDict(dict):
@@ -41,7 +73,7 @@ class SortedDict(dict):
iterkeys = __iter__
-class AddressBook(QtGui.QWidget):
+class AddressBook(QtWidgets.QWidget):
def __init__(self, parent=None):
super(AddressBook, self).__init__(parent)
@@ -49,23 +81,23 @@ class AddressBook(QtGui.QWidget):
self.oldName = ''
self.oldAddress = ''
- nameLabel = QtGui.QLabel("Name:")
- self.nameLine = QtGui.QLineEdit()
+ nameLabel = QtWidgets.QLabel("Name:")
+ self.nameLine = QtWidgets.QLineEdit()
self.nameLine.setReadOnly(True)
- addressLabel = QtGui.QLabel("Address:")
- self.addressText = QtGui.QTextEdit()
+ addressLabel = QtWidgets.QLabel("Address:")
+ self.addressText = QtWidgets.QTextEdit()
self.addressText.setReadOnly(True)
- self.addButton = QtGui.QPushButton("&Add")
+ self.addButton = QtWidgets.QPushButton("&Add")
self.addButton.show()
- self.submitButton = QtGui.QPushButton("&Submit")
+ self.submitButton = QtWidgets.QPushButton("&Submit")
self.submitButton.hide()
- self.cancelButton = QtGui.QPushButton("&Cancel")
+ self.cancelButton = QtWidgets.QPushButton("&Cancel")
self.cancelButton.hide()
- self.nextButton = QtGui.QPushButton("&Next")
+ self.nextButton = QtWidgets.QPushButton("&Next")
self.nextButton.setEnabled(False)
- self.previousButton = QtGui.QPushButton("&Previous")
+ self.previousButton = QtWidgets.QPushButton("&Previous")
self.previousButton.setEnabled(False)
self.addButton.clicked.connect(self.addContact)
@@ -74,17 +106,17 @@ class AddressBook(QtGui.QWidget):
self.nextButton.clicked.connect(self.next)
self.previousButton.clicked.connect(self.previous)
- buttonLayout1 = QtGui.QVBoxLayout()
+ buttonLayout1 = QtWidgets.QVBoxLayout()
buttonLayout1.addWidget(self.addButton, QtCore.Qt.AlignTop)
buttonLayout1.addWidget(self.submitButton)
buttonLayout1.addWidget(self.cancelButton)
buttonLayout1.addStretch()
- buttonLayout2 = QtGui.QHBoxLayout()
+ buttonLayout2 = QtWidgets.QHBoxLayout()
buttonLayout2.addWidget(self.previousButton)
buttonLayout2.addWidget(self.nextButton)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, QtCore.Qt.AlignTop)
@@ -117,16 +149,16 @@ class AddressBook(QtGui.QWidget):
address = self.addressText.toPlainText()
if name == "" or address == "":
- QtGui.QMessageBox.information(self, "Empty Field",
+ QtWidgets.QMessageBox.information(self, "Empty Field",
"Please enter a name and address.")
return
if name not in self.contacts:
self.contacts[name] = address
- QtGui.QMessageBox.information(self, "Add Successful",
+ QtWidgets.QMessageBox.information(self, "Add Successful",
"\"%s\" has been added to your address book." % name)
else:
- QtGui.QMessageBox.information(self, "Add Unsuccessful",
+ QtWidgets.QMessageBox.information(self, "Add Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
@@ -207,7 +239,7 @@ class AddressBook(QtGui.QWidget):
if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
addressBook = AddressBook()
addressBook.show()
diff --git a/examples/tutorials/addressbook/part4.py b/examples/tutorials/addressbook/part4.py
index 417c1ca..80ef325 100755
--- a/examples/tutorials/addressbook/part4.py
+++ b/examples/tutorials/addressbook/part4.py
@@ -2,14 +2,46 @@
#############################################################################
##
-## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-## Contact: Qt Software Information (qt-info@nokia.com)
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
class SortedDict(dict):
@@ -41,7 +73,7 @@ class SortedDict(dict):
iterkeys = __iter__
-class AddressBook(QtGui.QWidget):
+class AddressBook(QtWidgets.QWidget):
NavigationMode, AddingMode, EditingMode = range(3)
def __init__(self, parent=None):
@@ -52,28 +84,28 @@ class AddressBook(QtGui.QWidget):
self.oldAddress = ''
self.currentMode = self.NavigationMode
- nameLabel = QtGui.QLabel("Name:")
- self.nameLine = QtGui.QLineEdit()
+ nameLabel = QtWidgets.QLabel("Name:")
+ self.nameLine = QtWidgets.QLineEdit()
self.nameLine.setReadOnly(True)
- addressLabel = QtGui.QLabel("Address:")
- self.addressText = QtGui.QTextEdit()
+ addressLabel = QtWidgets.QLabel("Address:")
+ self.addressText = QtWidgets.QTextEdit()
self.addressText.setReadOnly(True)
- self.addButton = QtGui.QPushButton("&Add")
+ self.addButton = QtWidgets.QPushButton("&Add")
self.addButton.show()
- self.editButton = QtGui.QPushButton("&Edit")
+ self.editButton = QtWidgets.QPushButton("&Edit")
self.editButton.setEnabled(False)
- self.removeButton = QtGui.QPushButton("&Remove")
+ self.removeButton = QtWidgets.QPushButton("&Remove")
self.removeButton.setEnabled(False)
- self.submitButton = QtGui.QPushButton("&Submit")
+ self.submitButton = QtWidgets.QPushButton("&Submit")
self.submitButton.hide()
- self.cancelButton = QtGui.QPushButton("&Cancel")
+ self.cancelButton = QtWidgets.QPushButton("&Cancel")
self.cancelButton.hide()
- self.nextButton = QtGui.QPushButton("&Next")
+ self.nextButton = QtWidgets.QPushButton("&Next")
self.nextButton.setEnabled(False)
- self.previousButton = QtGui.QPushButton("&Previous")
+ self.previousButton = QtWidgets.QPushButton("&Previous")
self.previousButton.setEnabled(False)
self.addButton.clicked.connect(self.addContact)
@@ -84,7 +116,7 @@ class AddressBook(QtGui.QWidget):
self.nextButton.clicked.connect(self.next)
self.previousButton.clicked.connect(self.previous)
- buttonLayout1 = QtGui.QVBoxLayout()
+ buttonLayout1 = QtWidgets.QVBoxLayout()
buttonLayout1.addWidget(self.addButton)
buttonLayout1.addWidget(self.editButton)
buttonLayout1.addWidget(self.removeButton)
@@ -92,11 +124,11 @@ class AddressBook(QtGui.QWidget):
buttonLayout1.addWidget(self.cancelButton)
buttonLayout1.addStretch()
- buttonLayout2 = QtGui.QHBoxLayout()
+ buttonLayout2 = QtWidgets.QHBoxLayout()
buttonLayout2.addWidget(self.previousButton)
buttonLayout2.addWidget(self.nextButton)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, QtCore.Qt.AlignTop)
@@ -127,33 +159,33 @@ class AddressBook(QtGui.QWidget):
address = self.addressText.toPlainText()
if name == "" or address == "":
- QtGui.QMessageBox.information(self, "Empty Field",
+ QtWidgets.QMessageBox.information(self, "Empty Field",
"Please enter a name and address.")
return
if self.currentMode == self.AddingMode:
if name not in self.contacts:
self.contacts[name] = address
- QtGui.QMessageBox.information(self, "Add Successful",
+ QtWidgets.QMessageBox.information(self, "Add Successful",
"\"%s\" has been added to your address book." % name)
else:
- QtGui.QMessageBox.information(self, "Add Unsuccessful",
+ QtWidgets.QMessageBox.information(self, "Add Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
elif self.currentMode == self.EditingMode:
if self.oldName != name:
if name not in self.contacts:
- QtGui.QMessageBox.information(self, "Edit Successful",
+ QtWidgets.QMessageBox.information(self, "Edit Successful",
"\"%s\" has been edited in your address book." % self.oldName)
del self.contacts[self.oldName]
self.contacts[name] = address
else:
- QtGui.QMessageBox.information(self, "Edit Unsuccessful",
+ QtWidgets.QMessageBox.information(self, "Edit Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
elif self.oldAddress != address:
- QtGui.QMessageBox.information(self, "Edit Successful",
+ QtWidgets.QMessageBox.information(self, "Edit Successful",
"\"%s\" has been edited in your address book." % name)
self.contacts[name] = address
@@ -169,15 +201,15 @@ class AddressBook(QtGui.QWidget):
address = self.addressText.toPlainText()
if name in self.contacts:
- button = QtGui.QMessageBox.question(self, "Confirm Remove",
+ button = QtWidgets.QMessageBox.question(self, "Confirm Remove",
"Are you sure you want to remove \"%s\"?" % name,
- QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+ QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
- if button == QtGui.QMessageBox.Yes:
+ if button == QtWidgets.QMessageBox.Yes:
self.previous()
del self.contacts[name]
- QtGui.QMessageBox.information(self, "Remove Successful",
+ QtWidgets.QMessageBox.information(self, "Remove Successful",
"\"%s\" has been removed from your address book." % name)
self.updateInterface(self.NavigationMode)
@@ -261,7 +293,7 @@ class AddressBook(QtGui.QWidget):
if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
addressBook = AddressBook()
addressBook.show()
diff --git a/examples/tutorials/addressbook/part5.py b/examples/tutorials/addressbook/part5.py
index ef6aeaa..a40033c 100755
--- a/examples/tutorials/addressbook/part5.py
+++ b/examples/tutorials/addressbook/part5.py
@@ -2,14 +2,46 @@
#############################################################################
##
-## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-## Contact: Qt Software Information (qt-info@nokia.com)
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
class SortedDict(dict):
@@ -41,7 +73,7 @@ class SortedDict(dict):
iterkeys = __iter__
-class AddressBook(QtGui.QWidget):
+class AddressBook(QtWidgets.QWidget):
NavigationMode, AddingMode, EditingMode = range(3)
def __init__(self, parent=None):
@@ -52,30 +84,30 @@ class AddressBook(QtGui.QWidget):
self.oldAddress = ''
self.currentMode = self.NavigationMode
- nameLabel = QtGui.QLabel("Name:")
- self.nameLine = QtGui.QLineEdit()
+ nameLabel = QtWidgets.QLabel("Name:")
+ self.nameLine = QtWidgets.QLineEdit()
self.nameLine.setReadOnly(True)
- addressLabel = QtGui.QLabel("Address:")
- self.addressText = QtGui.QTextEdit()
+ addressLabel = QtWidgets.QLabel("Address:")
+ self.addressText = QtWidgets.QTextEdit()
self.addressText.setReadOnly(True)
- self.addButton = QtGui.QPushButton("&Add")
+ self.addButton = QtWidgets.QPushButton("&Add")
self.addButton.show()
- self.editButton = QtGui.QPushButton("&Edit")
+ self.editButton = QtWidgets.QPushButton("&Edit")
self.editButton.setEnabled(False)
- self.removeButton = QtGui.QPushButton("&Remove")
+ self.removeButton = QtWidgets.QPushButton("&Remove")
self.removeButton.setEnabled(False)
- self.findButton = QtGui.QPushButton("&Find")
+ self.findButton = QtWidgets.QPushButton("&Find")
self.findButton.setEnabled(False)
- self.submitButton = QtGui.QPushButton("&Submit")
+ self.submitButton = QtWidgets.QPushButton("&Submit")
self.submitButton.hide()
- self.cancelButton = QtGui.QPushButton("&Cancel")
+ self.cancelButton = QtWidgets.QPushButton("&Cancel")
self.cancelButton.hide()
- self.nextButton = QtGui.QPushButton("&Next")
+ self.nextButton = QtWidgets.QPushButton("&Next")
self.nextButton.setEnabled(False)
- self.previousButton = QtGui.QPushButton("&Previous")
+ self.previousButton = QtWidgets.QPushButton("&Previous")
self.previousButton.setEnabled(False)
self.dialog = FindDialog()
@@ -89,7 +121,7 @@ class AddressBook(QtGui.QWidget):
self.nextButton.clicked.connect(self.next)
self.previousButton.clicked.connect(self.previous)
- buttonLayout1 = QtGui.QVBoxLayout()
+ buttonLayout1 = QtWidgets.QVBoxLayout()
buttonLayout1.addWidget(self.addButton)
buttonLayout1.addWidget(self.editButton)
buttonLayout1.addWidget(self.removeButton)
@@ -98,11 +130,11 @@ class AddressBook(QtGui.QWidget):
buttonLayout1.addWidget(self.cancelButton)
buttonLayout1.addStretch()
- buttonLayout2 = QtGui.QHBoxLayout()
+ buttonLayout2 = QtWidgets.QHBoxLayout()
buttonLayout2.addWidget(self.previousButton)
buttonLayout2.addWidget(self.nextButton)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, QtCore.Qt.AlignTop)
@@ -133,33 +165,33 @@ class AddressBook(QtGui.QWidget):
address = self.addressText.toPlainText()
if name == "" or address == "":
- QtGui.QMessageBox.information(self, "Empty Field",
+ QtWidgets.QMessageBox.information(self, "Empty Field",
"Please enter a name and address.")
return
if self.currentMode == self.AddingMode:
if name not in self.contacts:
self.contacts[name] = address
- QtGui.QMessageBox.information(self, "Add Successful",
+ QtWidgets.QMessageBox.information(self, "Add Successful",
"\"%s\" has been added to your address book." % name)
else:
- QtGui.QMessageBox.information(self, "Add Unsuccessful",
+ QtWidgets.QMessageBox.information(self, "Add Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
elif self.currentMode == self.EditingMode:
if self.oldName != name:
if name not in self.contacts:
- QtGui.QMessageBox.information(self, "Edit Successful",
+ QtWidgets.QMessageBox.information(self, "Edit Successful",
"\"%s\" has been edited in your address book." % self.oldName)
del self.contacts[self.oldName]
self.contacts[name] = address
else:
- QtGui.QMessageBox.information(self, "Edit Unsuccessful",
+ QtWidgets.QMessageBox.information(self, "Edit Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
elif self.oldAddress != address:
- QtGui.QMessageBox.information(self, "Edit Successful",
+ QtWidgets.QMessageBox.information(self, "Edit Successful",
"\"%s\" has been edited in your address book." % name)
self.contacts[name] = address
@@ -175,15 +207,15 @@ class AddressBook(QtGui.QWidget):
address = self.addressText.toPlainText()
if name in self.contacts:
- button = QtGui.QMessageBox.question(self, "Confirm Remove",
+ button = QtWidgets.QMessageBox.question(self, "Confirm Remove",
"Are you sure you want to remove \"%s\"?" % name,
- QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+ QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
- if button == QtGui.QMessageBox.Yes:
+ if button == QtWidgets.QMessageBox.Yes:
self.previous()
del self.contacts[name]
- QtGui.QMessageBox.information(self, "Remove Successful",
+ QtWidgets.QMessageBox.information(self, "Remove Successful",
"\"%s\" has been removed from your address book." % name)
self.updateInterface(self.NavigationMode)
@@ -230,14 +262,14 @@ class AddressBook(QtGui.QWidget):
def findContact(self):
self.dialog.show()
- if self.dialog.exec_() == QtGui.QDialog.Accepted:
+ if self.dialog.exec_() == QtWidgets.QDialog.Accepted:
contactName = self.dialog.getFindText()
if contactName in self.contacts:
self.nameLine.setText(contactName)
self.addressText.setText(self.contacts[contactName])
else:
- QtGui.QMessageBox.information(self, "Contact Not Found",
+ QtWidgets.QMessageBox.information(self, "Contact Not Found",
"Sorry, \"%s\" is not in your address book." % contactName)
return
@@ -281,17 +313,17 @@ class AddressBook(QtGui.QWidget):
self.cancelButton.hide()
-class FindDialog(QtGui.QDialog):
+class FindDialog(QtWidgets.QDialog):
def __init__(self, parent=None):
super(FindDialog, self).__init__(parent)
- findLabel = QtGui.QLabel("Enter the name of a contact:")
- self.lineEdit = QtGui.QLineEdit()
+ findLabel = QtWidgets.QLabel("Enter the name of a contact:")
+ self.lineEdit = QtWidgets.QLineEdit()
- self.findButton = QtGui.QPushButton("&Find")
+ self.findButton = QtWidgets.QPushButton("&Find")
self.findText = ''
- layout = QtGui.QHBoxLayout()
+ layout = QtWidgets.QHBoxLayout()
layout.addWidget(findLabel)
layout.addWidget(self.lineEdit)
layout.addWidget(self.findButton)
@@ -306,7 +338,7 @@ class FindDialog(QtGui.QDialog):
text = self.lineEdit.text()
if not text:
- QtGui.QMessageBox.information(self, "Empty Field",
+ QtWidgets.QMessageBox.information(self, "Empty Field",
"Please enter a name.")
return
else:
@@ -321,7 +353,7 @@ class FindDialog(QtGui.QDialog):
if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
addressBook = AddressBook()
addressBook.show()
diff --git a/examples/tutorials/addressbook/part6.py b/examples/tutorials/addressbook/part6.py
index 9db505b..5476a27 100755
--- a/examples/tutorials/addressbook/part6.py
+++ b/examples/tutorials/addressbook/part6.py
@@ -2,16 +2,48 @@
#############################################################################
##
-## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-## Contact: Qt Software Information (qt-info@nokia.com)
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 pickle
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
class SortedDict(dict):
@@ -43,7 +75,7 @@ class SortedDict(dict):
iterkeys = __iter__
-class AddressBook(QtGui.QWidget):
+class AddressBook(QtWidgets.QWidget):
NavigationMode, AddingMode, EditingMode = range(3)
def __init__(self, parent=None):
@@ -54,35 +86,35 @@ class AddressBook(QtGui.QWidget):
self.oldAddress = ''
self.currentMode = self.NavigationMode
- nameLabel = QtGui.QLabel("Name:")
- self.nameLine = QtGui.QLineEdit()
+ nameLabel = QtWidgets.QLabel("Name:")
+ self.nameLine = QtWidgets.QLineEdit()
self.nameLine.setReadOnly(True)
- addressLabel = QtGui.QLabel("Address:")
- self.addressText = QtGui.QTextEdit()
+ addressLabel = QtWidgets.QLabel("Address:")
+ self.addressText = QtWidgets.QTextEdit()
self.addressText.setReadOnly(True)
- self.addButton = QtGui.QPushButton("&Add")
+ self.addButton = QtWidgets.QPushButton("&Add")
self.addButton.show()
- self.editButton = QtGui.QPushButton("&Edit")
+ self.editButton = QtWidgets.QPushButton("&Edit")
self.editButton.setEnabled(False)
- self.removeButton = QtGui.QPushButton("&Remove")
+ self.removeButton = QtWidgets.QPushButton("&Remove")
self.removeButton.setEnabled(False)
- self.findButton = QtGui.QPushButton("&Find")
+ self.findButton = QtWidgets.QPushButton("&Find")
self.findButton.setEnabled(False)
- self.submitButton = QtGui.QPushButton("&Submit")
+ self.submitButton = QtWidgets.QPushButton("&Submit")
self.submitButton.hide()
- self.cancelButton = QtGui.QPushButton("&Cancel")
+ self.cancelButton = QtWidgets.QPushButton("&Cancel")
self.cancelButton.hide()
- self.nextButton = QtGui.QPushButton("&Next")
+ self.nextButton = QtWidgets.QPushButton("&Next")
self.nextButton.setEnabled(False)
- self.previousButton = QtGui.QPushButton("&Previous")
+ self.previousButton = QtWidgets.QPushButton("&Previous")
self.previousButton.setEnabled(False)
- self.loadButton = QtGui.QPushButton("&Load...")
+ self.loadButton = QtWidgets.QPushButton("&Load...")
self.loadButton.setToolTip("Load contacts from a file")
- self.saveButton = QtGui.QPushButton("Sa&ve...")
+ self.saveButton = QtWidgets.QPushButton("Sa&ve...")
self.saveButton.setToolTip("Save contacts to a file")
self.saveButton.setEnabled(False)
@@ -99,7 +131,7 @@ class AddressBook(QtGui.QWidget):
self.loadButton.clicked.connect(self.loadFromFile)
self.saveButton.clicked.connect(self.saveToFile)
- buttonLayout1 = QtGui.QVBoxLayout()
+ buttonLayout1 = QtWidgets.QVBoxLayout()
buttonLayout1.addWidget(self.addButton)
buttonLayout1.addWidget(self.editButton)
buttonLayout1.addWidget(self.removeButton)
@@ -110,11 +142,11 @@ class AddressBook(QtGui.QWidget):
buttonLayout1.addWidget(self.saveButton)
buttonLayout1.addStretch()
- buttonLayout2 = QtGui.QHBoxLayout()
+ buttonLayout2 = QtWidgets.QHBoxLayout()
buttonLayout2.addWidget(self.previousButton)
buttonLayout2.addWidget(self.nextButton)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, QtCore.Qt.AlignTop)
@@ -145,33 +177,33 @@ class AddressBook(QtGui.QWidget):
address = self.addressText.toPlainText()
if name == "" or address == "":
- QtGui.QMessageBox.information(self, "Empty Field",
+ QtWidgets.QMessageBox.information(self, "Empty Field",
"Please enter a name and address.")
return
if self.currentMode == self.AddingMode:
if name not in self.contacts:
self.contacts[name] = address
- QtGui.QMessageBox.information(self, "Add Successful",
+ QtWidgets.QMessageBox.information(self, "Add Successful",
"\"%s\" has been added to your address book." % name)
else:
- QtGui.QMessageBox.information(self, "Add Unsuccessful",
+ QtWidgets.QMessageBox.information(self, "Add Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
elif self.currentMode == self.EditingMode:
if self.oldName != name:
if name not in self.contacts:
- QtGui.QMessageBox.information(self, "Edit Successful",
+ QtWidgets.QMessageBox.information(self, "Edit Successful",
"\"%s\" has been edited in your address book." % self.oldName)
del self.contacts[self.oldName]
self.contacts[name] = address
else:
- QtGui.QMessageBox.information(self, "Edit Unsuccessful",
+ QtWidgets.QMessageBox.information(self, "Edit Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
elif self.oldAddress != address:
- QtGui.QMessageBox.information(self, "Edit Successful",
+ QtWidgets.QMessageBox.information(self, "Edit Successful",
"\"%s\" has been edited in your address book." % name)
self.contacts[name] = address
@@ -187,15 +219,15 @@ class AddressBook(QtGui.QWidget):
address = self.addressText.toPlainText()
if name in self.contacts:
- button = QtGui.QMessageBox.question(self, "Confirm Remove",
+ button = QtWidgets.QMessageBox.question(self, "Confirm Remove",
"Are you sure you want to remove \"%s\"?" % name,
- QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+ QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
- if button == QtGui.QMessageBox.Yes:
+ if button == QtWidgets.QMessageBox.Yes:
self.previous()
del self.contacts[name]
- QtGui.QMessageBox.information(self, "Remove Successful",
+ QtWidgets.QMessageBox.information(self, "Remove Successful",
"\"%s\" has been removed from your address book." % name)
self.updateInterface(self.NavigationMode)
@@ -242,14 +274,14 @@ class AddressBook(QtGui.QWidget):
def findContact(self):
self.dialog.show()
- if self.dialog.exec_() == QtGui.QDialog.Accepted:
+ if self.dialog.exec_() == QtWidgets.QDialog.Accepted:
contactName = self.dialog.getFindText()
if contactName in self.contacts:
self.nameLine.setText(contactName)
self.addressText.setText(self.contacts[contactName])
else:
- QtGui.QMessageBox.information(self, "Contact Not Found",
+ QtWidgets.QMessageBox.information(self, "Contact Not Found",
"Sorry, \"%s\" is not in your address book." % contactName)
return
@@ -299,7 +331,7 @@ class AddressBook(QtGui.QWidget):
self.saveButton.setEnabled(number >= 1)
def saveToFile(self):
- fileName,_ = QtGui.QFileDialog.getSaveFileName(self,
+ fileName,_ = QtWidgets.QFileDialog.getSaveFileName(self,
"Save Address Book", '',
"Address Book (*.abk);;All Files (*)")
@@ -309,7 +341,7 @@ class AddressBook(QtGui.QWidget):
try:
out_file = open(str(fileName), 'wb')
except IOError:
- QtGui.QMessageBox.information(self, "Unable to open file",
+ QtWidgets.QMessageBox.information(self, "Unable to open file",
"There was an error opening \"%s\"" % fileName)
return
@@ -317,7 +349,7 @@ class AddressBook(QtGui.QWidget):
out_file.close()
def loadFromFile(self):
- fileName,_ = QtGui.QFileDialog.getOpenFileName(self,
+ fileName,_ = QtWidgets.QFileDialog.getOpenFileName(self,
"Open Address Book", '',
"Address Book (*.abk);;All Files (*)")
@@ -327,7 +359,7 @@ class AddressBook(QtGui.QWidget):
try:
in_file = open(str(fileName), 'rb')
except IOError:
- QtGui.QMessageBox.information(self, "Unable to open file",
+ QtWidgets.QMessageBox.information(self, "Unable to open file",
"There was an error opening \"%s\"" % fileName)
return
@@ -335,7 +367,7 @@ class AddressBook(QtGui.QWidget):
in_file.close()
if len(self.contacts) == 0:
- QtGui.QMessageBox.information(self, "No contacts in file",
+ QtWidgets.QMessageBox.information(self, "No contacts in file",
"The file you are attempting to open contains no "
"contacts.")
else:
@@ -346,17 +378,17 @@ class AddressBook(QtGui.QWidget):
self.updateInterface(self.NavigationMode)
-class FindDialog(QtGui.QDialog):
+class FindDialog(QtWidgets.QDialog):
def __init__(self, parent=None):
super(FindDialog, self).__init__(parent)
- findLabel = QtGui.QLabel("Enter the name of a contact:")
- self.lineEdit = QtGui.QLineEdit()
+ findLabel = QtWidgets.QLabel("Enter the name of a contact:")
+ self.lineEdit = QtWidgets.QLineEdit()
- self.findButton = QtGui.QPushButton("&Find")
+ self.findButton = QtWidgets.QPushButton("&Find")
self.findText = ''
- layout = QtGui.QHBoxLayout()
+ layout = QtWidgets.QHBoxLayout()
layout.addWidget(findLabel)
layout.addWidget(self.lineEdit)
layout.addWidget(self.findButton)
@@ -371,7 +403,7 @@ class FindDialog(QtGui.QDialog):
text = self.lineEdit.text()
if not text:
- QtGui.QMessageBox.information(self, "Empty Field",
+ QtWidgets.QMessageBox.information(self, "Empty Field",
"Please enter a name.")
return
@@ -386,7 +418,7 @@ class FindDialog(QtGui.QDialog):
if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
addressBook = AddressBook()
addressBook.show()
diff --git a/examples/tutorials/addressbook/part7.py b/examples/tutorials/addressbook/part7.py
index 2d5b87c..5458a75 100755
--- a/examples/tutorials/addressbook/part7.py
+++ b/examples/tutorials/addressbook/part7.py
@@ -2,16 +2,48 @@
#############################################################################
##
-## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-## Contact: Qt Software Information (qt-info@nokia.com)
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
##
-## This file is part of the example classes of the Qt Toolkit.
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 pickle
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
class SortedDict(dict):
@@ -43,7 +75,7 @@ class SortedDict(dict):
iterkeys = __iter__
-class AddressBook(QtGui.QWidget):
+class AddressBook(QtWidgets.QWidget):
NavigationMode, AddingMode, EditingMode = range(3)
def __init__(self, parent=None):
@@ -54,39 +86,39 @@ class AddressBook(QtGui.QWidget):
self.oldAddress = ''
self.currentMode = self.NavigationMode
- nameLabel = QtGui.QLabel("Name:")
- self.nameLine = QtGui.QLineEdit()
+ nameLabel = QtWidgets.QLabel("Name:")
+ self.nameLine = QtWidgets.QLineEdit()
self.nameLine.setReadOnly(True)
- addressLabel = QtGui.QLabel("Address:")
- self.addressText = QtGui.QTextEdit()
+ addressLabel = QtWidgets.QLabel("Address:")
+ self.addressText = QtWidgets.QTextEdit()
self.addressText.setReadOnly(True)
- self.addButton = QtGui.QPushButton("&Add")
+ self.addButton = QtWidgets.QPushButton("&Add")
self.addButton.show()
- self.editButton = QtGui.QPushButton("&Edit")
+ self.editButton = QtWidgets.QPushButton("&Edit")
self.editButton.setEnabled(False)
- self.removeButton = QtGui.QPushButton("&Remove")
+ self.removeButton = QtWidgets.QPushButton("&Remove")
self.removeButton.setEnabled(False)
- self.findButton = QtGui.QPushButton("&Find")
+ self.findButton = QtWidgets.QPushButton("&Find")
self.findButton.setEnabled(False)
- self.submitButton = QtGui.QPushButton("&Submit")
+ self.submitButton = QtWidgets.QPushButton("&Submit")
self.submitButton.hide()
- self.cancelButton = QtGui.QPushButton("&Cancel")
+ self.cancelButton = QtWidgets.QPushButton("&Cancel")
self.cancelButton.hide()
- self.nextButton = QtGui.QPushButton("&Next")
+ self.nextButton = QtWidgets.QPushButton("&Next")
self.nextButton.setEnabled(False)
- self.previousButton = QtGui.QPushButton("&Previous")
+ self.previousButton = QtWidgets.QPushButton("&Previous")
self.previousButton.setEnabled(False)
- self.loadButton = QtGui.QPushButton("&Load...")
+ self.loadButton = QtWidgets.QPushButton("&Load...")
self.loadButton.setToolTip("Load contacts from a file")
- self.saveButton = QtGui.QPushButton("Sa&ve...")
+ self.saveButton = QtWidgets.QPushButton("Sa&ve...")
self.saveButton.setToolTip("Save contacts to a file")
self.saveButton.setEnabled(False)
- self.exportButton = QtGui.QPushButton("Ex&port")
+ self.exportButton = QtWidgets.QPushButton("Ex&port")
self.exportButton.setToolTip("Export as vCard")
self.exportButton.setEnabled(False)
@@ -104,7 +136,7 @@ class AddressBook(QtGui.QWidget):
self.saveButton.clicked.connect(self.saveToFile)
self.exportButton.clicked.connect(self.exportAsVCard)
- buttonLayout1 = QtGui.QVBoxLayout()
+ buttonLayout1 = QtWidgets.QVBoxLayout()
buttonLayout1.addWidget(self.addButton)
buttonLayout1.addWidget(self.editButton)
buttonLayout1.addWidget(self.removeButton)
@@ -116,11 +148,11 @@ class AddressBook(QtGui.QWidget):
buttonLayout1.addWidget(self.exportButton)
buttonLayout1.addStretch()
- buttonLayout2 = QtGui.QHBoxLayout()
+ buttonLayout2 = QtWidgets.QHBoxLayout()
buttonLayout2.addWidget(self.previousButton)
buttonLayout2.addWidget(self.nextButton)
- mainLayout = QtGui.QGridLayout()
+ mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(nameLabel, 0, 0)
mainLayout.addWidget(self.nameLine, 0, 1)
mainLayout.addWidget(addressLabel, 1, 0, QtCore.Qt.AlignTop)
@@ -151,33 +183,33 @@ class AddressBook(QtGui.QWidget):
address = self.addressText.toPlainText()
if name == "" or address == "":
- QtGui.QMessageBox.information(self, "Empty Field",
+ QtWidgets.QMessageBox.information(self, "Empty Field",
"Please enter a name and address.")
return
if self.currentMode == self.AddingMode:
if name not in self.contacts:
self.contacts[name] = address
- QtGui.QMessageBox.information(self, "Add Successful",
+ QtWidgets.QMessageBox.information(self, "Add Successful",
"\"%s\" has been added to your address book." % name)
else:
- QtGui.QMessageBox.information(self, "Add Unsuccessful",
+ QtWidgets.QMessageBox.information(self, "Add Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
elif self.currentMode == self.EditingMode:
if self.oldName != name:
if name not in self.contacts:
- QtGui.QMessageBox.information(self, "Edit Successful",
+ QtWidgets.QMessageBox.information(self, "Edit Successful",
"\"%s\" has been edited in your address book." % self.oldName)
del self.contacts[self.oldName]
self.contacts[name] = address
else:
- QtGui.QMessageBox.information(self, "Edit Unsuccessful",
+ QtWidgets.QMessageBox.information(self, "Edit Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
elif self.oldAddress != address:
- QtGui.QMessageBox.information(self, "Edit Successful",
+ QtWidgets.QMessageBox.information(self, "Edit Successful",
"\"%s\" has been edited in your address book." % name)
self.contacts[name] = address
@@ -193,15 +225,15 @@ class AddressBook(QtGui.QWidget):
address = self.addressText.toPlainText()
if name in self.contacts:
- button = QtGui.QMessageBox.question(self, "Confirm Remove",
+ button = QtWidgets.QMessageBox.question(self, "Confirm Remove",
"Are you sure you want to remove \"%s\"?" % name,
- QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+ QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
- if button == QtGui.QMessageBox.Yes:
+ if button == QtWidgets.QMessageBox.Yes:
self.previous()
del self.contacts[name]
- QtGui.QMessageBox.information(self, "Remove Successful",
+ QtWidgets.QMessageBox.information(self, "Remove Successful",
"\"%s\" has been removed from your address book." % name)
self.updateInterface(self.NavigationMode)
@@ -248,14 +280,14 @@ class AddressBook(QtGui.QWidget):
def findContact(self):
self.dialog.show()
- if self.dialog.exec_() == QtGui.QDialog.Accepted:
+ if self.dialog.exec_() == QtWidgets.QDialog.Accepted:
contactName = self.dialog.getFindText()
if contactName in self.contacts:
self.nameLine.setText(contactName)
self.addressText.setText(self.contacts[contactName])
else:
- QtGui.QMessageBox.information(self, "Contact Not Found",
+ QtWidgets.QMessageBox.information(self, "Contact Not Found",
"Sorry, \"%s\" is not in your address book." % contactName)
return
@@ -308,7 +340,7 @@ class AddressBook(QtGui.QWidget):
self.saveButton.setEnabled(number >= 1)
def saveToFile(self):
- fileName,_ = QtGui.QFileDialog.getSaveFileName(self,
+ fileName,_ = QtWidgets.QFileDialog.getSaveFileName(self,
"Save Address Book", '',
"Address Book (*.abk);;All Files (*)")
@@ -318,7 +350,7 @@ class AddressBook(QtGui.QWidget):
try:
out_file = open(str(fileName), 'wb')
except IOError:
- QtGui.QMessageBox.information(self, "Unable to open file",
+ QtWidgets.QMessageBox.information(self, "Unable to open file",
"There was an error opening \"%s\"" % fileName)
return
@@ -326,7 +358,7 @@ class AddressBook(QtGui.QWidget):
out_file.close()
def loadFromFile(self):
- fileName,_ = QtGui.QFileDialog.getOpenFileName(self,
+ fileName,_ = QtWidgets.QFileDialog.getOpenFileName(self,
"Open Address Book", '',
"Address Book (*.abk);;All Files (*)")
@@ -336,7 +368,7 @@ class AddressBook(QtGui.QWidget):
try:
in_file = open(str(fileName), 'rb')
except IOError:
- QtGui.QMessageBox.information(self, "Unable to open file",
+ QtWidgets.QMessageBox.information(self, "Unable to open file",
"There was an error opening \"%s\"" % fileName)
return
@@ -344,7 +376,7 @@ class AddressBook(QtGui.QWidget):
in_file.close()
if len(self.contacts) == 0:
- QtGui.QMessageBox.information(self, "No contacts in file",
+ QtWidgets.QMessageBox.information(self, "No contacts in file",
"The file you are attempting to open contains no "
"contacts.")
else:
@@ -367,7 +399,7 @@ class AddressBook(QtGui.QWidget):
firstName = name
lastName = ''
- fileName = QtGui.QFileDialog.getSaveFileName(self, "Export Contact",
+ fileName = QtWidgets.QFileDialog.getSaveFileName(self, "Export Contact",
'', "vCard Files (*.vcf);;All Files (*)")[0]
if not fileName:
@@ -376,7 +408,7 @@ class AddressBook(QtGui.QWidget):
out_file = QtCore.QFile(fileName)
if not out_file.open(QtCore.QIODevice.WriteOnly):
- QtGui.QMessageBox.information(self, "Unable to open file",
+ QtWidgets.QMessageBox.information(self, "Unable to open file",
out_file.errorString())
return
@@ -394,21 +426,21 @@ class AddressBook(QtGui.QWidget):
out_s << 'ADR;HOME:;' << address << '\n'
out_s << 'END:VCARD' << '\n'
- QtGui.QMessageBox.information(self, "Export Successful",
+ QtWidgets.QMessageBox.information(self, "Export Successful",
"\"%s\" has been exported as a vCard." % name)
-class FindDialog(QtGui.QDialog):
+class FindDialog(QtWidgets.QDialog):
def __init__(self, parent=None):
super(FindDialog, self).__init__(parent)
- findLabel = QtGui.QLabel("Enter the name of a contact:")
- self.lineEdit = QtGui.QLineEdit()
+ findLabel = QtWidgets.QLabel("Enter the name of a contact:")
+ self.lineEdit = QtWidgets.QLineEdit()
- self.findButton = QtGui.QPushButton("&Find")
+ self.findButton = QtWidgets.QPushButton("&Find")
self.findText = ''
- layout = QtGui.QHBoxLayout()
+ layout = QtWidgets.QHBoxLayout()
layout.addWidget(findLabel)
layout.addWidget(self.lineEdit)
layout.addWidget(self.findButton)
@@ -423,7 +455,7 @@ class FindDialog(QtGui.QDialog):
text = self.lineEdit.text()
if not text:
- QtGui.QMessageBox.information(self, "Empty Field",
+ QtWidgets.QMessageBox.information(self, "Empty Field",
"Please enter a name.")
return
@@ -438,7 +470,7 @@ class FindDialog(QtGui.QDialog):
if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
addressBook = AddressBook()
addressBook.show()
diff --git a/examples/widgets/tetrix.py b/examples/widgets/tetrix.py
index 62b5469..e4639a8 100755..100644
--- a/examples/widgets/tetrix.py
+++ b/examples/widgets/tetrix.py
@@ -1,48 +1,89 @@
#!/usr/bin/env python
-"""PyQt4 port of the widgets/tetrix example from Qt v4.x"""
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/widgets/tetrix example from Qt v5.x"""
import random
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
NoShape, ZShape, SShape, LineShape, TShape, SquareShape, LShape, MirroredLShape = range(8)
-class TetrixWindow(QtGui.QWidget):
+class TetrixWindow(QtWidgets.QWidget):
def __init__(self):
super(TetrixWindow, self).__init__()
self.board = TetrixBoard()
- nextPieceLabel = QtGui.QLabel()
- nextPieceLabel.setFrameStyle(QtGui.QFrame.Box | QtGui.QFrame.Raised)
+ nextPieceLabel = QtWidgets.QLabel()
+ nextPieceLabel.setFrameStyle(QtWidgets.QFrame.Box | QtWidgets.QFrame.Raised)
nextPieceLabel.setAlignment(QtCore.Qt.AlignCenter)
self.board.setNextPieceLabel(nextPieceLabel)
- scoreLcd = QtGui.QLCDNumber(5)
- scoreLcd.setSegmentStyle(QtGui.QLCDNumber.Filled)
- levelLcd = QtGui.QLCDNumber(2)
- levelLcd.setSegmentStyle(QtGui.QLCDNumber.Filled)
- linesLcd = QtGui.QLCDNumber(5)
- linesLcd.setSegmentStyle(QtGui.QLCDNumber.Filled)
+ scoreLcd = QtWidgets.QLCDNumber(5)
+ scoreLcd.setSegmentStyle(QtWidgets.QLCDNumber.Filled)
+ levelLcd = QtWidgets.QLCDNumber(2)
+ levelLcd.setSegmentStyle(QtWidgets.QLCDNumber.Filled)
+ linesLcd = QtWidgets.QLCDNumber(5)
+ linesLcd.setSegmentStyle(QtWidgets.QLCDNumber.Filled)
- startButton = QtGui.QPushButton("&Start")
+ startButton = QtWidgets.QPushButton("&Start")
startButton.setFocusPolicy(QtCore.Qt.NoFocus)
- quitButton = QtGui.QPushButton("&Quit")
+ quitButton = QtWidgets.QPushButton("&Quit")
quitButton.setFocusPolicy(QtCore.Qt.NoFocus)
- pauseButton = QtGui.QPushButton("&Pause")
+ pauseButton = QtWidgets.QPushButton("&Pause")
pauseButton.setFocusPolicy(QtCore.Qt.NoFocus)
startButton.clicked.connect(self.board.start)
pauseButton.clicked.connect(self.board.pause)
- quitButton.clicked.connect(QtGui.qApp.quit)
+ quitButton.clicked.connect(QtWidgets.qApp.quit)
self.board.scoreChanged.connect(scoreLcd.display)
self.board.levelChanged.connect(levelLcd.display)
self.board.linesRemovedChanged.connect(linesLcd.display)
- layout = QtGui.QGridLayout()
+ layout = QtWidgets.QGridLayout()
layout.addWidget(self.createLabel("NEXT"), 0, 0)
layout.addWidget(nextPieceLabel, 1, 0)
layout.addWidget(self.createLabel("LEVEL"), 2, 0)
@@ -61,12 +102,12 @@ class TetrixWindow(QtGui.QWidget):
self.resize(550, 370)
def createLabel(self, text):
- lbl = QtGui.QLabel(text)
+ lbl = QtWidgets.QLabel(text)
lbl.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom)
return lbl
-class TetrixBoard(QtGui.QFrame):
+class TetrixBoard(QtWidgets.QFrame):
BoardWidth = 10
BoardHeight = 22
@@ -92,7 +133,7 @@ class TetrixBoard(QtGui.QFrame):
self.level = 0
self.board = None
- self.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken)
+ self.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Sunken)
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self.isStarted = False
self.isPaused = False
@@ -451,7 +492,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
window = TetrixWindow()
window.show()
random.seed(None)
diff --git a/examples/xml/dombookmarks/dombookmarks.py b/examples/xml/dombookmarks/dombookmarks.py
index c7d11c4..77c2bad 100755
--- a/examples/xml/dombookmarks/dombookmarks.py
+++ b/examples/xml/dombookmarks/dombookmarks.py
@@ -1,11 +1,52 @@
#!/usr/bin/env python
-"""PyQt4 port of the xml/dombookmarks example from Qt v4.x"""
-
-from PySide2 import QtCore, QtGui, QtXml
-
-
-class MainWindow(QtGui.QMainWindow):
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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$
+##
+#############################################################################
+
+"""PySide2 port of the xml/dombookmarks example from Qt v5.x"""
+
+from PySide2 import QtCore, QtGui, QtWidgets, QtXml
+
+
+class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
@@ -21,7 +62,7 @@ class MainWindow(QtGui.QMainWindow):
self.resize(480, 320)
def open(self):
- fileName = QtGui.QFileDialog.getOpenFileName(self,
+ fileName = QtWidgets.QFileDialog.getOpenFileName(self,
"Open Bookmark File", QtCore.QDir.currentPath(),
"XBEL Files (*.xbel *.xml)")[0]
@@ -30,7 +71,7 @@ class MainWindow(QtGui.QMainWindow):
inFile = QtCore.QFile(fileName)
if not inFile.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text):
- QtGui.QMessageBox.warning(self, "DOM Bookmarks",
+ QtWidgets.QMessageBox.warning(self, "DOM Bookmarks",
"Cannot read file %s:\n%s." % (fileName, inFile.errorString()))
return
@@ -38,7 +79,7 @@ class MainWindow(QtGui.QMainWindow):
self.statusBar().showMessage("File loaded", 2000)
def saveAs(self):
- fileName = QtGui.QFileDialog.getSaveFileName(self,
+ fileName = QtWidgets.QFileDialog.getSaveFileName(self,
"Save Bookmark File", QtCore.QDir.currentPath(),
"XBEL Files (*.xbel *.xml)")[0]
@@ -47,7 +88,7 @@ class MainWindow(QtGui.QMainWindow):
outFile = QtCore.QFile(fileName)
if not outFile.open(QtCore.QFile.WriteOnly | QtCore.QFile.Text):
- QtGui.QMessageBox.warning(self, "DOM Bookmarks",
+ QtWidgets.QMessageBox.warning(self, "DOM Bookmarks",
"Cannot write file %s:\n%s." % (fileName, outFile.errorString()))
return
@@ -55,24 +96,24 @@ class MainWindow(QtGui.QMainWindow):
self.statusBar().showMessage("File saved", 2000)
def about(self):
- QtGui.QMessageBox.about(self, "About DOM Bookmarks",
+ QtWidgets.QMessageBox.about(self, "About DOM Bookmarks",
"The <b>DOM Bookmarks</b> example demonstrates how to use Qt's "
"DOM classes to read and write XML documents.")
def createActions(self):
- self.openAct = QtGui.QAction("&Open...", self, shortcut="Ctrl+O",
+ self.openAct = QtWidgets.QAction("&Open...", self, shortcut="Ctrl+O",
triggered=self.open)
- self.saveAsAct = QtGui.QAction("&Save As...", self, shortcut="Ctrl+S",
+ self.saveAsAct = QtWidgets.QAction("&Save As...", self, shortcut="Ctrl+S",
triggered=self.saveAs)
- self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q",
+ self.exitAct = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+Q",
triggered=self.close)
- self.aboutAct = QtGui.QAction("&About", self, triggered=self.about)
+ self.aboutAct = QtWidgets.QAction("&About", self, triggered=self.about)
- self.aboutQtAct = QtGui.QAction("About &Qt", self,
- triggered=QtGui.qApp.aboutQt)
+ self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
+ triggered=QtWidgets.qApp.aboutQt)
def createMenus(self):
self.fileMenu = self.menuBar().addMenu("&File")
@@ -87,11 +128,11 @@ class MainWindow(QtGui.QMainWindow):
self.helpMenu.addAction(self.aboutQtAct)
-class XbelTree(QtGui.QTreeWidget):
+class XbelTree(QtWidgets.QTreeWidget):
def __init__(self, parent=None):
super(XbelTree, self).__init__(parent)
- self.header().setResizeMode(QtGui.QHeaderView.Stretch)
+ self.header().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
self.setHeaderLabels(("Title", "Location"))
self.domDocument = QtXml.QDomDocument()
@@ -101,26 +142,26 @@ class XbelTree(QtGui.QTreeWidget):
self.folderIcon = QtGui.QIcon()
self.bookmarkIcon = QtGui.QIcon()
- self.folderIcon.addPixmap(self.style().standardPixmap(QtGui.QStyle.SP_DirClosedIcon),
+ self.folderIcon.addPixmap(self.style().standardPixmap(QtWidgets.QStyle.SP_DirClosedIcon),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
- self.folderIcon.addPixmap(self.style().standardPixmap(QtGui.QStyle.SP_DirOpenIcon),
+ self.folderIcon.addPixmap(self.style().standardPixmap(QtWidgets.QStyle.SP_DirOpenIcon),
QtGui.QIcon.Normal, QtGui.QIcon.On)
- self.bookmarkIcon.addPixmap(self.style().standardPixmap(QtGui.QStyle.SP_FileIcon))
+ self.bookmarkIcon.addPixmap(self.style().standardPixmap(QtWidgets.QStyle.SP_FileIcon))
def read(self, device):
ok, errorStr, errorLine, errorColumn = self.domDocument.setContent(device, True)
if not ok:
- QtGui.QMessageBox.information(self.window(), "DOM Bookmarks",
+ QtWidgets.QMessageBox.information(self.window(), "DOM Bookmarks",
"Parse error at line %d, column %d:\n%s" % (errorLine, errorColumn, errorStr))
return False
root = self.domDocument.documentElement()
if root.tagName() != 'xbel':
- QtGui.QMessageBox.information(self.window(), "DOM Bookmarks",
+ QtWidgets.QMessageBox.information(self.window(), "DOM Bookmarks",
"The file is not an XBEL file.")
return False
elif root.hasAttribute('version') and root.attribute('version') != '1.0':
- QtGui.QMessageBox.information(self.window(), "DOM Bookmarks",
+ QtWidgets.QMessageBox.information(self.window(), "DOM Bookmarks",
"The file is not an XBEL version 1.0 file.")
return False
@@ -200,12 +241,12 @@ class XbelTree(QtGui.QTreeWidget):
child = child.nextSiblingElement()
def createItem(self, element, parentItem=None):
- item = QtGui.QTreeWidgetItem()
+ item = QtWidgets.QTreeWidgetItem()
if parentItem is not None:
- item = QtGui.QTreeWidgetItem(parentItem)
+ item = QtWidgets.QTreeWidgetItem(parentItem)
else:
- item = QtGui.QTreeWidgetItem(self)
+ item = QtWidgets.QTreeWidgetItem(self)
self.domElementForItem[id(item)] = element
return item
@@ -215,7 +256,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
mainWin.open()
diff --git a/examples/xmlpatterns/schema/schema.py b/examples/xmlpatterns/schema/schema.py
index bdc33df..1a3c51e 100755
--- a/examples/xmlpatterns/schema/schema.py
+++ b/examples/xmlpatterns/schema/schema.py
@@ -1,7 +1,47 @@
#!/usr/bin/env python
-
-from PySide2 import QtCore, QtGui, QtXmlPatterns
+#############################################################################
+##
+## Copyright (C) 2013 Riverbank Computing Limited.
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: http://www.qt.io/licensing/
+##
+## This file is part of the PySide examples of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:BSD$
+## 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 import QtCore, QtGui, QtWidgets, QtXmlPatterns
import schema_rc
from ui_schema import Ui_SchemaMainWindow
@@ -111,10 +151,10 @@ class MessageHandler(QtXmlPatterns.QAbstractMessageHandler):
self.m_sourceLocation = sourceLocation
-class MainWindow(QtGui.QMainWindow, Ui_SchemaMainWindow):
+class MainWindow(QtWidgets.QMainWindow, Ui_SchemaMainWindow):
def __init__(self):
- QtGui.QMainWindow.__init__(self)
+ QtWidgets.QMainWindow.__init__(self)
self.setupUi(self)
@@ -161,6 +201,9 @@ class MainWindow(QtGui.QMainWindow, Ui_SchemaMainWindow):
self.validate()
def instanceSelected(self, index):
+ if index is -1:
+ return
+
index += 2 * self.schemaSelection.currentIndex()
instanceFile = QtCore.QFile(':/instance_%d.xml' % index)
instanceFile.open(QtCore.QIODevice.ReadOnly)
@@ -211,7 +254,7 @@ class MainWindow(QtGui.QMainWindow, Ui_SchemaMainWindow):
self.instanceEdit.moveCursor(QtGui.QTextCursor.Right)
extraSelections = []
- selection = QtGui.QTextEdit.ExtraSelection()
+ selection = QtWidgets.QTextEdit.ExtraSelection()
lineColor = QtGui.QColor(QtCore.Qt.red).lighter(160)
selection.format.setBackground(lineColor)
@@ -229,7 +272,7 @@ if __name__ == '__main__':
import sys
- app = QtGui.QApplication(sys.argv)
+ app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
diff --git a/examples/xmlpatterns/schema/ui_schema.py b/examples/xmlpatterns/schema/ui_schema.py
index 62a97b6..a5690c2 100644
--- a/examples/xmlpatterns/schema/ui_schema.py
+++ b/examples/xmlpatterns/schema/ui_schema.py
@@ -7,45 +7,45 @@
#
# WARNING! All changes made in this file will be lost!
-from PySide2 import QtCore, QtGui
+from PySide2 import QtCore, QtGui, QtWidgets
class Ui_SchemaMainWindow(object):
def setupUi(self, SchemaMainWindow):
SchemaMainWindow.setObjectName("SchemaMainWindow")
SchemaMainWindow.resize(417, 594)
- self.centralwidget = QtGui.QWidget(SchemaMainWindow)
+ self.centralwidget = QtWidgets.QWidget(SchemaMainWindow)
self.centralwidget.setObjectName("centralwidget")
- self.gridLayout = QtGui.QGridLayout(self.centralwidget)
+ self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
- self.schemaLabel = QtGui.QLabel(self.centralwidget)
+ self.schemaLabel = QtWidgets.QLabel(self.centralwidget)
self.schemaLabel.setObjectName("schemaLabel")
self.gridLayout.addWidget(self.schemaLabel, 0, 0, 1, 2)
- self.schemaSelection = QtGui.QComboBox(self.centralwidget)
+ self.schemaSelection = QtWidgets.QComboBox(self.centralwidget)
self.schemaSelection.setObjectName("schemaSelection")
self.gridLayout.addWidget(self.schemaSelection, 0, 2, 1, 2)
- self.schemaView = QtGui.QTextBrowser(self.centralwidget)
+ self.schemaView = QtWidgets.QTextBrowser(self.centralwidget)
self.schemaView.setObjectName("schemaView")
self.gridLayout.addWidget(self.schemaView, 1, 0, 1, 4)
- self.instanceLabel = QtGui.QLabel(self.centralwidget)
+ self.instanceLabel = QtWidgets.QLabel(self.centralwidget)
self.instanceLabel.setObjectName("instanceLabel")
self.gridLayout.addWidget(self.instanceLabel, 2, 0, 1, 2)
- self.instanceSelection = QtGui.QComboBox(self.centralwidget)
+ self.instanceSelection = QtWidgets.QComboBox(self.centralwidget)
self.instanceSelection.setObjectName("instanceSelection")
self.gridLayout.addWidget(self.instanceSelection, 2, 2, 1, 2)
- self.instanceEdit = QtGui.QTextEdit(self.centralwidget)
+ self.instanceEdit = QtWidgets.QTextEdit(self.centralwidget)
self.instanceEdit.setObjectName("instanceEdit")
self.gridLayout.addWidget(self.instanceEdit, 3, 0, 1, 4)
- self.label = QtGui.QLabel(self.centralwidget)
+ self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 4, 0, 1, 1)
- self.validationStatus = QtGui.QLabel(self.centralwidget)
+ self.validationStatus = QtWidgets.QLabel(self.centralwidget)
self.validationStatus.setObjectName("validationStatus")
self.gridLayout.addWidget(self.validationStatus, 4, 1, 1, 2)
- self.validateButton = QtGui.QPushButton(self.centralwidget)
+ self.validateButton = QtWidgets.QPushButton(self.centralwidget)
self.validateButton.setObjectName("validateButton")
self.gridLayout.addWidget(self.validateButton, 4, 3, 1, 1)
SchemaMainWindow.setCentralWidget(self.centralwidget)
- self.statusbar = QtGui.QStatusBar(SchemaMainWindow)
+ self.statusbar = QtWidgets.QStatusBar(SchemaMainWindow)
self.statusbar.setObjectName("statusbar")
SchemaMainWindow.setStatusBar(self.statusbar)
@@ -53,10 +53,10 @@ class Ui_SchemaMainWindow(object):
QtCore.QMetaObject.connectSlotsByName(SchemaMainWindow)
def retranslateUi(self, SchemaMainWindow):
- SchemaMainWindow.setWindowTitle(QtGui.QApplication.translate("SchemaMainWindow", "XML Schema Validation", None, QtGui.QApplication.UnicodeUTF8))
- self.schemaLabel.setText(QtGui.QApplication.translate("SchemaMainWindow", "XML Schema Document:", None, QtGui.QApplication.UnicodeUTF8))
- self.instanceLabel.setText(QtGui.QApplication.translate("SchemaMainWindow", "XML Instance Document:", None, QtGui.QApplication.UnicodeUTF8))
- self.label.setText(QtGui.QApplication.translate("SchemaMainWindow", "Status:", None, QtGui.QApplication.UnicodeUTF8))
- self.validationStatus.setText(QtGui.QApplication.translate("SchemaMainWindow", "not validated", None, QtGui.QApplication.UnicodeUTF8))
- self.validateButton.setText(QtGui.QApplication.translate("SchemaMainWindow", "Validate", None, QtGui.QApplication.UnicodeUTF8))
+ SchemaMainWindow.setWindowTitle(QtWidgets.QApplication.translate("SchemaMainWindow", "XML Schema Validation", None))
+ self.schemaLabel.setText(QtWidgets.QApplication.translate("SchemaMainWindow", "XML Schema Document:", None))
+ self.instanceLabel.setText(QtWidgets.QApplication.translate("SchemaMainWindow", "XML Instance Document:", None))
+ self.label.setText(QtWidgets.QApplication.translate("SchemaMainWindow", "Status:", None))
+ self.validationStatus.setText(QtWidgets.QApplication.translate("SchemaMainWindow", "not validated", None))
+ self.validateButton.setText(QtWidgets.QApplication.translate("SchemaMainWindow", "Validate", None))