aboutsummaryrefslogtreecommitdiffstats
path: root/examples/widgets/painting
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-01-05 15:58:35 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-01-12 12:28:10 +0000
commit9f2a9aba3aff73e31ea15eb4a7a04b0e50f4ee4e (patch)
tree92dcb0c4f64df8a8375af2e1a9bb1170068c36b2 /examples/widgets/painting
parent26c046e521c38bbfc3a263782a3bb74a7c1bf937 (diff)
Move examples from submodule to pyside-setup
Move PySide2 examples that are owned by the Qt Company to a new examples directory. Done-with: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Task-number: PYSIDE-363 Change-Id: I14099764d9eef2bc35e067086121427955862e3a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'examples/widgets/painting')
-rwxr-xr-xexamples/widgets/painting/basicdrawing/basicdrawing.py350
-rw-r--r--examples/widgets/painting/basicdrawing/basicdrawing.qrc6
-rw-r--r--examples/widgets/painting/basicdrawing/basicdrawing_rc.py174
-rw-r--r--examples/widgets/painting/basicdrawing/images/brick.pngbin0 -> 856 bytes
-rw-r--r--examples/widgets/painting/basicdrawing/images/qt-logo.pngbin0 -> 533 bytes
-rwxr-xr-xexamples/widgets/painting/concentriccircles.py147
6 files changed, 677 insertions, 0 deletions
diff --git a/examples/widgets/painting/basicdrawing/basicdrawing.py b/examples/widgets/painting/basicdrawing/basicdrawing.py
new file mode 100755
index 000000000..c2f3e672c
--- /dev/null
+++ b/examples/widgets/painting/basicdrawing/basicdrawing.py
@@ -0,0 +1,350 @@
+#!/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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/painting/basicdrawing example from Qt v5.x, originating from PyQt"""
+
+from PySide2.QtCore import QPoint, QRect, QSize, Qt, qVersion
+from PySide2.QtGui import (QBrush, QConicalGradient, QLinearGradient, QPainter,
+ QPainterPath, QPalette, QPen, QPixmap, QPolygon, QRadialGradient)
+from PySide2.QtWidgets import (QApplication, QCheckBox, QComboBox, QGridLayout,
+ QLabel, QSpinBox, QWidget)
+
+import basicdrawing_rc
+
+
+class RenderArea(QWidget):
+ points = QPolygon([
+ QPoint(10, 80),
+ QPoint(20, 10),
+ QPoint(80, 30),
+ QPoint(90, 70)
+ ])
+
+ Line, Points, Polyline, Polygon, Rect, RoundedRect, Ellipse, Arc, Chord, \
+ Pie, Path, Text, Pixmap = range(13)
+
+ def __init__(self, parent=None):
+ super(RenderArea, self).__init__(parent)
+
+ self.pen = QPen()
+ self.brush = QBrush()
+ self.pixmap = QPixmap()
+
+ self.shape = RenderArea.Polygon
+ self.antialiased = False
+ self.transformed = False
+ self.pixmap.load(':/images/qt-logo.png')
+
+ self.setBackgroundRole(QPalette.Base)
+ self.setAutoFillBackground(True)
+
+ def minimumSizeHint(self):
+ return QSize(100, 100)
+
+ def sizeHint(self):
+ return QSize(400, 200)
+
+ def setShape(self, shape):
+ self.shape = shape
+ self.update()
+
+ def setPen(self, pen):
+ self.pen = pen
+ self.update()
+
+ def setBrush(self, brush):
+ self.brush = brush
+ self.update()
+
+ def setAntialiased(self, antialiased):
+ self.antialiased = antialiased
+ self.update()
+
+ def setTransformed(self, transformed):
+ self.transformed = transformed
+ self.update()
+
+ def paintEvent(self, event):
+ rect = QRect(10, 20, 80, 60)
+
+ path = QPainterPath()
+ path.moveTo(20, 80)
+ path.lineTo(20, 30)
+ path.cubicTo(80, 0, 50, 50, 80, 80)
+
+ startAngle = 30 * 16
+ arcLength = 120 * 16
+
+ painter = QPainter(self)
+ painter.setPen(self.pen)
+ painter.setBrush(self.brush)
+ if self.antialiased:
+ painter.setRenderHint(QPainter.Antialiasing)
+
+ for x in range(0, self.width(), 100):
+ for y in range(0, self.height(), 100):
+ painter.save()
+ painter.translate(x, y)
+ if self.transformed:
+ painter.translate(50, 50)
+ painter.rotate(60.0)
+ painter.scale(0.6, 0.9)
+ painter.translate(-50, -50)
+
+ if self.shape == RenderArea.Line:
+ painter.drawLine(rect.bottomLeft(), rect.topRight())
+ elif self.shape == RenderArea.Points:
+ painter.drawPoints(RenderArea.points)
+ elif self.shape == RenderArea.Polyline:
+ painter.drawPolyline(RenderArea.points)
+ elif self.shape == RenderArea.Polygon:
+ painter.drawPolygon(RenderArea.points)
+ elif self.shape == RenderArea.Rect:
+ painter.drawRect(rect)
+ elif self.shape == RenderArea.RoundedRect:
+ painter.drawRoundedRect(rect, 25, 25, Qt.RelativeSize)
+ elif self.shape == RenderArea.Ellipse:
+ painter.drawEllipse(rect)
+ elif self.shape == RenderArea.Arc:
+ painter.drawArc(rect, startAngle, arcLength)
+ elif self.shape == RenderArea.Chord:
+ painter.drawChord(rect, startAngle, arcLength)
+ elif self.shape == RenderArea.Pie:
+ painter.drawPie(rect, startAngle, arcLength)
+ elif self.shape == RenderArea.Path:
+ painter.drawPath(path)
+ elif self.shape == RenderArea.Text:
+ painter.drawText(rect, Qt.AlignCenter,
+ "PySide 2\nQt %s" % qVersion())
+ elif self.shape == RenderArea.Pixmap:
+ painter.drawPixmap(10, 10, self.pixmap)
+
+ painter.restore()
+
+ painter.setPen(self.palette().dark().color())
+ painter.setBrush(Qt.NoBrush)
+ painter.drawRect(QRect(0, 0, self.width() - 1, self.height() - 1))
+
+
+IdRole = Qt.UserRole
+
+class Window(QWidget):
+ def __init__(self):
+ super(Window, self).__init__()
+
+ self.renderArea = RenderArea()
+
+ self.shapeComboBox = QComboBox()
+ self.shapeComboBox.addItem("Polygon", RenderArea.Polygon)
+ self.shapeComboBox.addItem("Rectangle", RenderArea.Rect)
+ self.shapeComboBox.addItem("Rounded Rectangle", RenderArea.RoundedRect)
+ self.shapeComboBox.addItem("Ellipse", RenderArea.Ellipse)
+ self.shapeComboBox.addItem("Pie", RenderArea.Pie)
+ self.shapeComboBox.addItem("Chord", RenderArea.Chord)
+ self.shapeComboBox.addItem("Path", RenderArea.Path)
+ self.shapeComboBox.addItem("Line", RenderArea.Line)
+ self.shapeComboBox.addItem("Polyline", RenderArea.Polyline)
+ self.shapeComboBox.addItem("Arc", RenderArea.Arc)
+ self.shapeComboBox.addItem("Points", RenderArea.Points)
+ self.shapeComboBox.addItem("Text", RenderArea.Text)
+ self.shapeComboBox.addItem("Pixmap", RenderArea.Pixmap)
+
+ shapeLabel = QLabel("&Shape:")
+ shapeLabel.setBuddy(self.shapeComboBox)
+
+ self.penWidthSpinBox = QSpinBox()
+ self.penWidthSpinBox.setRange(0, 20)
+ self.penWidthSpinBox.setSpecialValueText("0 (cosmetic pen)")
+
+ penWidthLabel = QLabel("Pen &Width:")
+ penWidthLabel.setBuddy(self.penWidthSpinBox)
+
+ self.penStyleComboBox = QComboBox()
+ self.penStyleComboBox.addItem("Solid", Qt.SolidLine)
+ self.penStyleComboBox.addItem("Dash", Qt.DashLine)
+ self.penStyleComboBox.addItem("Dot", Qt.DotLine)
+ self.penStyleComboBox.addItem("Dash Dot", Qt.DashDotLine)
+ self.penStyleComboBox.addItem("Dash Dot Dot", Qt.DashDotDotLine)
+ self.penStyleComboBox.addItem("None", Qt.NoPen)
+
+ penStyleLabel = QLabel("&Pen Style:")
+ penStyleLabel.setBuddy(self.penStyleComboBox)
+
+ self.penCapComboBox = QComboBox()
+ self.penCapComboBox.addItem("Flat", Qt.FlatCap)
+ self.penCapComboBox.addItem("Square", Qt.SquareCap)
+ self.penCapComboBox.addItem("Round", Qt.RoundCap)
+
+ penCapLabel = QLabel("Pen &Cap:")
+ penCapLabel.setBuddy(self.penCapComboBox)
+
+ self.penJoinComboBox = QComboBox()
+ self.penJoinComboBox.addItem("Miter", Qt.MiterJoin)
+ self.penJoinComboBox.addItem("Bevel", Qt.BevelJoin)
+ self.penJoinComboBox.addItem("Round", Qt.RoundJoin)
+
+ penJoinLabel = QLabel("Pen &Join:")
+ penJoinLabel.setBuddy(self.penJoinComboBox)
+
+ self.brushStyleComboBox = QComboBox()
+ self.brushStyleComboBox.addItem("Linear Gradient",
+ Qt.LinearGradientPattern)
+ self.brushStyleComboBox.addItem("Radial Gradient",
+ Qt.RadialGradientPattern)
+ self.brushStyleComboBox.addItem("Conical Gradient",
+ Qt.ConicalGradientPattern)
+ self.brushStyleComboBox.addItem("Texture", Qt.TexturePattern)
+ self.brushStyleComboBox.addItem("Solid", Qt.SolidPattern)
+ self.brushStyleComboBox.addItem("Horizontal", Qt.HorPattern)
+ self.brushStyleComboBox.addItem("Vertical", Qt.VerPattern)
+ self.brushStyleComboBox.addItem("Cross", Qt.CrossPattern)
+ self.brushStyleComboBox.addItem("Backward Diagonal", Qt.BDiagPattern)
+ self.brushStyleComboBox.addItem("Forward Diagonal", Qt.FDiagPattern)
+ self.brushStyleComboBox.addItem("Diagonal Cross", Qt.DiagCrossPattern)
+ self.brushStyleComboBox.addItem("Dense 1", Qt.Dense1Pattern)
+ self.brushStyleComboBox.addItem("Dense 2", Qt.Dense2Pattern)
+ self.brushStyleComboBox.addItem("Dense 3", Qt.Dense3Pattern)
+ self.brushStyleComboBox.addItem("Dense 4", Qt.Dense4Pattern)
+ self.brushStyleComboBox.addItem("Dense 5", Qt.Dense5Pattern)
+ self.brushStyleComboBox.addItem("Dense 6", Qt.Dense6Pattern)
+ self.brushStyleComboBox.addItem("Dense 7", Qt.Dense7Pattern)
+ self.brushStyleComboBox.addItem("None", Qt.NoBrush)
+
+ brushStyleLabel = QLabel("&Brush Style:")
+ brushStyleLabel.setBuddy(self.brushStyleComboBox)
+
+ otherOptionsLabel = QLabel("Other Options:")
+ self.antialiasingCheckBox = QCheckBox("&Antialiasing")
+ self.transformationsCheckBox = QCheckBox("&Transformations")
+
+ self.shapeComboBox.activated.connect(self.shapeChanged)
+ self.penWidthSpinBox.valueChanged.connect(self.penChanged)
+ self.penStyleComboBox.activated.connect(self.penChanged)
+ self.penCapComboBox.activated.connect(self.penChanged)
+ self.penJoinComboBox.activated.connect(self.penChanged)
+ self.brushStyleComboBox.activated.connect(self.brushChanged)
+ self.antialiasingCheckBox.toggled.connect(self.renderArea.setAntialiased)
+ self.transformationsCheckBox.toggled.connect(self.renderArea.setTransformed)
+
+ mainLayout = QGridLayout()
+ mainLayout.setColumnStretch(0, 1)
+ mainLayout.setColumnStretch(3, 1)
+ mainLayout.addWidget(self.renderArea, 0, 0, 1, 4)
+ mainLayout.setRowMinimumHeight(1, 6)
+ mainLayout.addWidget(shapeLabel, 2, 1, Qt.AlignRight)
+ mainLayout.addWidget(self.shapeComboBox, 2, 2)
+ mainLayout.addWidget(penWidthLabel, 3, 1, Qt.AlignRight)
+ mainLayout.addWidget(self.penWidthSpinBox, 3, 2)
+ mainLayout.addWidget(penStyleLabel, 4, 1, Qt.AlignRight)
+ mainLayout.addWidget(self.penStyleComboBox, 4, 2)
+ mainLayout.addWidget(penCapLabel, 5, 1, Qt.AlignRight)
+ mainLayout.addWidget(self.penCapComboBox, 5, 2)
+ mainLayout.addWidget(penJoinLabel, 6, 1, Qt.AlignRight)
+ mainLayout.addWidget(self.penJoinComboBox, 6, 2)
+ mainLayout.addWidget(brushStyleLabel, 7, 1, Qt.AlignRight)
+ mainLayout.addWidget(self.brushStyleComboBox, 7, 2)
+ mainLayout.setRowMinimumHeight(8, 6)
+ mainLayout.addWidget(otherOptionsLabel, 9, 1, Qt.AlignRight)
+ mainLayout.addWidget(self.antialiasingCheckBox, 9, 2)
+ mainLayout.addWidget(self.transformationsCheckBox, 10, 2)
+ self.setLayout(mainLayout)
+
+ self.shapeChanged()
+ self.penChanged()
+ self.brushChanged()
+ self.antialiasingCheckBox.setChecked(True)
+
+ self.setWindowTitle("Basic Drawing")
+
+ def shapeChanged(self):
+ shape = self.shapeComboBox.itemData(self.shapeComboBox.currentIndex(),
+ IdRole)
+ self.renderArea.setShape(shape)
+
+ def penChanged(self):
+ width = self.penWidthSpinBox.value()
+ style = Qt.PenStyle(self.penStyleComboBox.itemData(
+ self.penStyleComboBox.currentIndex(), IdRole))
+ cap = Qt.PenCapStyle(self.penCapComboBox.itemData(
+ self.penCapComboBox.currentIndex(), IdRole))
+ join = Qt.PenJoinStyle(self.penJoinComboBox.itemData(
+ self.penJoinComboBox.currentIndex(), IdRole))
+
+ self.renderArea.setPen(QPen(Qt.blue, width, style, cap, join))
+
+ def brushChanged(self):
+ style = Qt.BrushStyle(self.brushStyleComboBox.itemData(
+ self.brushStyleComboBox.currentIndex(), IdRole))
+
+ if style == Qt.LinearGradientPattern:
+ linearGradient = QLinearGradient(0, 0, 100, 100)
+ linearGradient.setColorAt(0.0, Qt.white)
+ linearGradient.setColorAt(0.2, Qt.green)
+ linearGradient.setColorAt(1.0, Qt.black)
+ self.renderArea.setBrush(QBrush(linearGradient))
+ elif style == Qt.RadialGradientPattern:
+ radialGradient = QRadialGradient(50, 50, 50, 70, 70)
+ radialGradient.setColorAt(0.0, Qt.white)
+ radialGradient.setColorAt(0.2, Qt.green)
+ radialGradient.setColorAt(1.0, Qt.black)
+ self.renderArea.setBrush(QBrush(radialGradient))
+ elif style == Qt.ConicalGradientPattern:
+ conicalGradient = QConicalGradient(50, 50, 150)
+ conicalGradient.setColorAt(0.0, Qt.white)
+ conicalGradient.setColorAt(0.2, Qt.green)
+ conicalGradient.setColorAt(1.0, Qt.black)
+ self.renderArea.setBrush(QBrush(conicalGradient))
+ elif style == Qt.TexturePattern:
+ self.renderArea.setBrush(QBrush(QPixmap(':/images/brick.png')))
+ else:
+ self.renderArea.setBrush(QBrush(Qt.green, style))
+
+
+if __name__ == '__main__':
+
+ import sys
+
+ app = QApplication(sys.argv)
+ window = Window()
+ window.show()
+ sys.exit(app.exec_())
diff --git a/examples/widgets/painting/basicdrawing/basicdrawing.qrc b/examples/widgets/painting/basicdrawing/basicdrawing.qrc
new file mode 100644
index 000000000..9d8a23a1c
--- /dev/null
+++ b/examples/widgets/painting/basicdrawing/basicdrawing.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/brick.png</file>
+ <file>images/qt-logo.png</file>
+</qresource>
+</RCC>
diff --git a/examples/widgets/painting/basicdrawing/basicdrawing_rc.py b/examples/widgets/painting/basicdrawing/basicdrawing_rc.py
new file mode 100644
index 000000000..b9de90387
--- /dev/null
+++ b/examples/widgets/painting/basicdrawing/basicdrawing_rc.py
@@ -0,0 +1,174 @@
+#############################################################################
+##
+## 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$
+##
+#############################################################################
+
+# Resource object code
+#
+# Created: Wed Dec 28 19:54:31 2005
+# by: The Resource Compiler for PyQt (Qt v4.1.0)
+#
+# WARNING! All changes made in this file will be lost!
+
+from PySide2 import QtCore
+
+qt_resource_data = b"\
+\x00\x00\x03\x58\
+\x89\
+\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
+\x00\x00\x20\x00\x00\x00\x10\x08\x02\x00\x00\x00\xf8\x62\xea\x0e\
+\x00\x00\x00\x04\x67\x41\x4d\x41\x00\x00\xb1\x8e\x7c\xfb\x51\x93\
+\x00\x00\x00\x20\x63\x48\x52\x4d\x00\x00\x7a\x25\x00\x00\x80\x83\
+\x00\x00\xf9\xff\x00\x00\x80\xe8\x00\x00\x75\x30\x00\x00\xea\x60\
+\x00\x00\x3a\x97\x00\x00\x17\x6f\x97\xa9\x99\xd4\x00\x00\x02\xe3\
+\x49\x44\x41\x54\x38\xcb\x45\x94\xcb\x8d\x1e\x45\x10\xc7\x7f\x55\
+\xd5\x33\xb3\xf6\x6a\x9d\x09\x49\x90\x04\x0e\x05\x09\x99\x78\xe0\
+\xc4\xc1\x12\x07\x42\x20\x04\x08\xc1\x96\xd7\xcb\xb7\xf3\xcd\xf4\
+\xa3\xaa\x38\x4c\x5b\xee\x73\xbd\xfa\xff\x92\xcf\xff\xfc\xa6\x86\
+\x1a\x28\x2a\x20\x64\x42\x92\x41\x04\x38\x1e\xa4\x93\x41\x38\x39\
+\x40\x11\x41\x94\x8c\x59\x93\x57\x41\x42\x62\x2b\x65\xc3\x16\xac\
+\x20\x85\xf7\x3f\xbd\x2f\x08\xf5\xf6\x6f\xd9\x50\x25\x0c\x35\xc4\
+\x48\xc7\x3b\x31\x18\x8d\x18\xa4\x13\x4e\x74\x7c\x20\x82\x16\x80\
+\x74\xdc\xf1\x46\x0c\xc2\x11\x00\xa4\xb0\xbc\xe1\xe1\x09\xdb\xf8\
+\xf5\xc3\x87\x0c\x8a\x1a\xaa\xd4\x97\xbf\xcb\x82\x2e\xf3\x04\x9c\
+\xa8\xd4\x9d\x7e\xa7\x9f\xf3\xd8\xd1\xf0\x93\x70\xb4\x20\x82\x77\
+\xfa\xc1\x68\x10\x44\x02\xa8\x62\x0b\xeb\x23\xfd\x1d\x7f\xfe\xf5\
+\x31\x02\x51\x8a\x16\xd4\x10\xa5\xdd\x3e\x6a\x61\x7b\x22\x20\x06\
+\x7d\xe7\xfc\xc2\xf9\x1f\xc7\x33\xf5\x75\x82\xd0\x76\x46\x45\x94\
+\x18\x78\xa7\xef\x8c\x8e\x2a\xde\xc9\xc4\x0a\xdb\x3b\x1e\x9e\x58\
+\x1e\xf1\x0e\x01\x50\x44\x10\xc3\x0a\x61\x94\x07\xca\x86\x2e\x84\
+\x93\x01\x4c\x32\xc6\x81\x0f\xd2\x69\x07\x5e\x01\xc4\x88\x81\x18\
+\x0c\xbc\x33\x1a\xd1\xf1\x42\xd9\x68\x85\x4c\x62\x90\x49\x06\xe5\
+\xc2\x54\x0c\x51\x6c\x45\x0b\x19\x64\xe2\x83\x76\xe7\xf8\x4a\xdb\
+\x49\x68\x77\xc6\x9d\xd1\x89\x41\x06\xb6\x20\x4a\x3f\x21\x18\x8d\
+\xbe\x93\x49\x11\xbc\x61\x1b\xfd\xa0\xef\x8c\x13\xef\x17\x07\x05\
+\x51\x44\x11\x21\x9c\x51\xa9\x37\xce\x17\x8e\xaf\xd4\xdb\xe4\x60\
+\x9c\xdc\xbf\x90\x17\xb7\x83\xf5\x11\x51\xfa\x7d\x76\x89\x92\x8e\
+\x08\x11\x78\x87\xa4\x9f\xf4\x93\x51\x2f\x88\x14\xb9\x78\x1b\x8c\
+\xca\xf9\xc2\xf1\xc2\xf1\x3c\xfb\xc9\x89\xd5\x68\x78\xbb\xb4\x42\
+\x0c\x80\x51\x51\xa3\x6c\x2c\x6f\x21\x27\x6e\x5e\x51\x9d\xda\x8d\
+\xa0\x44\x00\x98\x12\x2b\x80\x57\xfa\x49\xbb\x51\x6f\xb4\x57\x32\
+\x09\x67\x1c\x64\xa0\x85\x7e\xc7\x3b\x5a\xe8\x8a\x15\xc8\x39\xb7\
+\xac\x08\x88\x52\x1e\xa6\x82\x33\x41\x20\x29\x17\x99\x62\xa8\x11\
+\x8e\x77\xbc\x11\x41\x38\x75\xa7\x1f\x53\x91\xa3\x7e\xf7\x97\x77\
+\x32\x88\x95\x70\x60\xee\x36\xc3\x16\x96\x47\x32\xbe\x41\xa7\x20\
+\x14\x51\x08\x62\xd0\x0e\x54\x19\x95\xe8\x4c\x62\x8c\x4c\x46\x65\
+\x1c\xd4\x1d\x3f\x49\x07\x21\x83\x14\xa2\x91\x49\xef\xa0\xac\x6f\
+\x91\x85\x64\xb2\x7d\xad\xbc\x0e\x2a\x99\x78\xa7\xed\xec\x9f\xb0\
+\x85\x18\x93\x0f\x35\xca\x4a\x37\x86\x53\x5f\x69\xfb\x34\xd4\x25\
+\x41\x35\x10\x46\x23\x1d\x35\xfa\x1d\x35\xb2\x93\x81\x28\x6a\x13\
+\x15\x5b\x28\x31\xe8\x07\xf7\x67\xf6\x4f\xac\x4f\xa8\xe1\x8d\x51\
+\x21\xb0\x82\x95\xef\x6e\xb8\xac\x24\x42\x0f\x60\xc6\x43\x79\x83\
+\x6d\x84\xd3\x4f\x00\xdb\xe6\xee\xeb\x44\x2b\x94\x70\x7c\xf0\xc7\
+\xef\x1f\x23\xd8\x9e\xa6\x4b\x11\xa2\xd1\x76\xda\x9d\xfa\x4a\xbb\
+\x31\x2a\x97\xf5\x2f\x45\x66\x80\x20\x8a\x1e\x58\xc5\xf6\xc9\xa2\
+\x1a\xba\x00\x94\x6f\x9b\x4a\x38\xbf\xfc\xfc\xe1\x32\x9e\xad\x88\
+\xcc\x54\xf1\x41\xdd\x89\x2b\xf2\xea\x4c\xba\xab\x87\x2b\x68\xa1\
+\xac\xe8\x82\x74\x54\x41\xd0\x05\x55\x00\x51\x74\x41\x8d\x4c\xe4\
+\xc7\x1f\x40\x67\x16\x5e\xc0\x5d\xef\x92\x53\xe6\x84\x3e\x06\x04\
+\x57\x5d\x06\xe4\xfc\x41\x59\xbf\xb5\x08\x57\x6e\x8a\xce\x39\x97\
+\xe4\xfe\x07\xb6\x84\x15\x24\x5c\xbc\x4f\xce\x00\x00\x00\x00\x49\
+\x45\x4e\x44\xae\x42\x60\x82\
+\x00\x00\x02\x15\
+\x89\
+\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
+\x00\x00\x50\x00\x00\x00\x50\x04\x03\x00\x00\x00\x7c\x3f\xef\x9e\
+\x00\x00\x00\x15\x50\x4c\x54\x45\xa3\xc2\x00\xf4\xf8\xe1\x8a\xa1\
+\x09\x14\x14\x18\x3f\x47\x16\xd3\xe2\x86\x70\x82\x0e\xfd\x17\x22\
+\x39\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x00\x48\x00\x00\x00\
+\x48\x00\x46\xc9\x6b\x3e\x00\x00\x01\xa6\x49\x44\x41\x54\x48\xc7\
+\xed\x56\x4b\x6e\x84\x30\x0c\x45\x66\xc4\x39\xa2\x49\xd5\x35\x22\
+\x11\x6b\xd4\x48\x73\x0e\x54\x10\xf7\x3f\x42\x0b\xc4\x4c\xfc\x83\
+\xd9\x75\xd1\xf1\x0a\xa2\x97\x17\xdb\xb1\x9f\x53\x55\x6f\xfb\x6b\
+\xbb\x2f\xcb\xfd\x1a\x05\x73\x0a\xbf\x16\x1f\xee\x1c\xd7\x6c\xb0\
+\x0d\x3a\x9e\xe2\x42\x61\xe3\x8b\xb8\x13\x24\x24\x0a\x8c\x96\x9f\
+\x53\x60\xd6\xeb\xb8\x5b\x10\x36\xa8\xc0\x24\x81\xf1\x45\x42\x9d\
+\x12\x09\xe3\x63\x59\xe6\x64\x53\x62\x6a\xf6\x2b\x81\xd9\xa4\xf4\
+\x19\x87\xff\x1f\x56\xe0\x89\xaf\xe7\x64\x39\x3d\x14\x27\xd2\x3f\
+\xa8\x27\x7f\xc9\xbd\x9d\x7a\xf2\x93\x6e\xc4\x35\x16\x37\xb0\xdd\
+\x7e\x75\xb6\x56\x4a\xe3\x46\xd7\x60\xfb\x06\xc5\xc9\x9a\x9e\xe2\
+\xf7\xf8\x93\x74\x72\x22\x4b\x90\xe9\x6b\x99\xc9\x44\x0e\xf1\x19\
+\xd0\xc8\x68\x52\x99\x44\xc0\x02\x07\x91\x72\x20\x5b\xf3\x6d\xb6\
+\x6c\xff\x51\x11\x3d\x25\x5c\x9d\x9c\x78\x7e\x08\x30\x13\x76\xf8\
+\x39\xf0\x34\x76\x94\xd0\x61\xd6\x04\xb0\x15\x84\xfb\xba\x01\x84\
+\xb2\xa9\x75\xe0\x50\x12\xf6\xd5\x05\x23\x84\x6b\xc6\xb6\x20\xcc\
+\x94\x37\x33\x6a\xa0\xca\x23\xa2\x3e\xf2\xe8\xa9\x9e\x78\x15\x18\
+\x09\xa1\x7e\x33\x78\xd7\x35\x93\x28\x71\xd7\xb8\x02\x54\x1f\x81\
+\x36\x52\x59\x8f\x9b\x53\x1d\xe6\x52\xa9\x47\xac\x70\x28\x98\x42\
+\x98\x64\x85\x1f\x3d\xb3\x77\x4b\x11\x3c\xeb\x99\xa3\x0b\x61\x73\
+\x1e\x4c\xe5\x7b\xf6\xb5\xef\x2a\x9a\x4f\xa7\x29\x85\xcb\x1a\x51\
+\x50\x46\x55\x7b\x3a\xae\x82\x52\x7b\x1a\x76\x0e\x98\xe2\xcc\xf5\
+\x11\x29\x2d\xc5\x3d\x90\xb3\x35\xbe\x50\xc3\x7b\xaa\xe1\xa6\x36\
+\xb3\xa9\xa0\x51\xaa\x73\xe6\x94\x92\xdb\x78\x31\x84\x4f\xa6\xd7\
+\xa4\xe2\xe2\x0b\xf3\x7a\xb2\xc6\x61\x93\x64\x85\xc7\x8b\xb7\xc7\
+\x1e\x84\xb7\x46\x36\x7f\xa5\x80\x41\xb8\xda\x92\xdf\x3d\xf9\x62\
+\x87\xb3\x97\xd4\xe7\xf7\xf1\x92\x02\xf7\x7e\x59\xfe\x3f\xfb\x01\
+\xbd\xf6\xdd\x91\xa2\xf3\xda\xd4\x00\x00\x00\x00\x49\x45\x4e\x44\
+\xae\x42\x60\x82\
+"
+
+qt_resource_name = b"\
+\x00\x06\
+\x07\x03\x7d\xc3\
+\x00\x69\
+\x00\x6d\x00\x61\x00\x67\x00\x65\x00\x73\
+\x00\x09\
+\x0f\x9e\x84\x47\
+\x00\x62\
+\x00\x72\x00\x69\x00\x63\x00\x6b\x00\x2e\x00\x70\x00\x6e\x00\x67\
+\x00\x0b\
+\x05\x52\xbf\x27\
+\x00\x71\
+\x00\x74\x00\x2d\x00\x6c\x00\x6f\x00\x67\x00\x6f\x00\x2e\x00\x70\x00\x6e\x00\x67\
+"
+
+qt_resource_struct = b"\
+\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
+\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\
+\x00\x00\x00\x2a\x00\x00\x00\x00\x00\x01\x00\x00\x03\x5c\
+\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
+"
+
+def qInitResources():
+ QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
+
+def qCleanupResources():
+ QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
+
+qInitResources()
diff --git a/examples/widgets/painting/basicdrawing/images/brick.png b/examples/widgets/painting/basicdrawing/images/brick.png
new file mode 100644
index 000000000..ab5e383dc
--- /dev/null
+++ b/examples/widgets/painting/basicdrawing/images/brick.png
Binary files differ
diff --git a/examples/widgets/painting/basicdrawing/images/qt-logo.png b/examples/widgets/painting/basicdrawing/images/qt-logo.png
new file mode 100644
index 000000000..9c27cf63a
--- /dev/null
+++ b/examples/widgets/painting/basicdrawing/images/qt-logo.png
Binary files differ
diff --git a/examples/widgets/painting/concentriccircles.py b/examples/widgets/painting/concentriccircles.py
new file mode 100755
index 000000000..5fecfc0b5
--- /dev/null
+++ b/examples/widgets/painting/concentriccircles.py
@@ -0,0 +1,147 @@
+#!/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$
+##
+#############################################################################
+
+"""PySide2 port of the widgets/painting/concentriccircles example from Qt v5.x, originating from PyQt"""
+
+from PySide2.QtCore import QRect, QRectF, QSize, Qt, QTimer
+from PySide2.QtGui import QColor, QPainter, QPalette, QPen
+from PySide2.QtWidgets import (QApplication, QFrame, QGridLayout, QLabel,
+ QSizePolicy, QWidget)
+
+
+class CircleWidget(QWidget):
+ def __init__(self, parent=None):
+ super(CircleWidget, self).__init__(parent)
+
+ self.floatBased = False
+ self.antialiased = False
+ self.frameNo = 0
+
+ self.setBackgroundRole(QPalette.Base)
+ self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+
+ def setFloatBased(self, floatBased):
+ self.floatBased = floatBased
+ self.update()
+
+ def setAntialiased(self, antialiased):
+ self.antialiased = antialiased
+ self.update()
+
+ def minimumSizeHint(self):
+ return QSize(50, 50)
+
+ def sizeHint(self):
+ return QSize(180, 180)
+
+ def nextAnimationFrame(self):
+ self.frameNo += 1
+ self.update()
+
+ def paintEvent(self, event):
+ painter = QPainter(self)
+ painter.setRenderHint(QPainter.Antialiasing, self.antialiased)
+ painter.translate(self.width() / 2, self.height() / 2)
+
+ for diameter in range(0, 256, 9):
+ delta = abs((self.frameNo % 128) - diameter / 2)
+ alpha = 255 - (delta * delta) / 4 - diameter
+ if alpha > 0:
+ painter.setPen(QPen(QColor(0, diameter / 2, 127, alpha), 3))
+
+ if self.floatBased:
+ painter.drawEllipse(QRectF(-diameter / 2.0,
+ -diameter / 2.0, diameter, diameter))
+ else:
+ painter.drawEllipse(QRect(-diameter / 2,
+ -diameter / 2, diameter, diameter))
+
+
+class Window(QWidget):
+ def __init__(self):
+ super(Window, self).__init__()
+
+ aliasedLabel = self.createLabel("Aliased")
+ antialiasedLabel = self.createLabel("Antialiased")
+ intLabel = self.createLabel("Int")
+ floatLabel = self.createLabel("Float")
+
+ layout = QGridLayout()
+ layout.addWidget(aliasedLabel, 0, 1)
+ layout.addWidget(antialiasedLabel, 0, 2)
+ layout.addWidget(intLabel, 1, 0)
+ layout.addWidget(floatLabel, 2, 0)
+
+ timer = QTimer(self)
+
+ for i in range(2):
+ for j in range(2):
+ w = CircleWidget()
+ w.setAntialiased(j != 0)
+ w.setFloatBased(i != 0)
+
+ timer.timeout.connect(w.nextAnimationFrame)
+
+ layout.addWidget(w, i + 1, j + 1)
+
+ timer.start(100)
+ self.setLayout(layout)
+
+ self.setWindowTitle("Concentric Circles")
+
+ def createLabel(self, text):
+ label = QLabel(text)
+ label.setAlignment(Qt.AlignCenter)
+ label.setMargin(2)
+ label.setFrameStyle(QFrame.Box | QFrame.Sunken)
+ return label
+
+
+if __name__ == '__main__':
+
+ import sys
+
+ app = QApplication(sys.argv)
+ window = Window()
+ window.show()
+ sys.exit(app.exec_())