aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/axcontainer/axviewer.py3
-rw-r--r--examples/corelib/threads/mandelbrot.py4
-rw-r--r--examples/corelib/tools/codecs/codecs.py253
-rw-r--r--examples/corelib/tools/settingseditor/settingseditor.py16
-rw-r--r--examples/external/matplotlib/widget_3dplot.py4
-rw-r--r--examples/external/opencv/webcam_pattern_detection.py4
-rw-r--r--examples/external/scikit/staining_colors_separation.py4
-rw-r--r--examples/multimedia/camera.py4
-rw-r--r--examples/multimedia/player.py6
-rw-r--r--examples/network/fortuneclient.py2
-rw-r--r--examples/opengl/2dpainting.py172
-rw-r--r--examples/opengl/contextinfo.py5
-rw-r--r--examples/opengl/grabber.py437
-rw-r--r--examples/opengl/hellogl.py287
-rw-r--r--examples/opengl/hellogl2.py12
-rw-r--r--examples/opengl/opengl.pyproject4
-rw-r--r--examples/opengl/overpainting.py385
-rw-r--r--examples/opengl/samplebuffers.py192
-rw-r--r--examples/samplebinding/CMakeLists.txt4
-rw-r--r--examples/script/README.md9
-rw-r--r--examples/script/helloscript.py60
-rw-r--r--examples/script/script.pyproject3
-rw-r--r--examples/scriptableapplication/CMakeLists.txt4
-rw-r--r--examples/scriptableapplication/mainwindow.cpp2
-rw-r--r--examples/webenginewidgets/tabbedbrowser/main.py4
-rw-r--r--examples/widgetbinding/CMakeLists.txt4
-rw-r--r--examples/widgets/animation/easing/easing.py2
-rw-r--r--examples/widgets/codeeditor/codeeditor.py2
-rw-r--r--examples/widgets/dialogs/standarddialogs.py2
-rw-r--r--examples/widgets/gallery/widgetgallery.py4
-rw-r--r--examples/widgets/graphicsview/diagramscene/diagramscene.py24
-rw-r--r--examples/widgets/itemviews/addressbook/addressbook.py3
-rw-r--r--examples/widgets/mainwindows/application/application.py20
-rw-r--r--examples/widgets/mainwindows/dockwidgets/dockwidgets.py6
-rw-r--r--examples/widgets/mainwindows/mdi/mdi.py6
-rw-r--r--examples/widgets/state-machine/rogue.py5
-rw-r--r--examples/widgets/systray/window.py4
-rw-r--r--examples/widgets/widgets/hellogl_openglwidget_legacy.py288
-rw-r--r--examples/xml/dombookmarks/dombookmarks.py10
-rw-r--r--examples/xmlpatterns/schema/files/contact.xsd25
-rw-r--r--examples/xmlpatterns/schema/files/invalid_contact.xml11
-rw-r--r--examples/xmlpatterns/schema/files/invalid_order.xml13
-rw-r--r--examples/xmlpatterns/schema/files/invalid_recipe.xml14
-rw-r--r--examples/xmlpatterns/schema/files/order.xsd23
-rw-r--r--examples/xmlpatterns/schema/files/recipe.xsd40
-rw-r--r--examples/xmlpatterns/schema/files/valid_contact.xml11
-rw-r--r--examples/xmlpatterns/schema/files/valid_order.xml18
-rw-r--r--examples/xmlpatterns/schema/files/valid_recipe.xml13
-rw-r--r--examples/xmlpatterns/schema/schema.py286
-rw-r--r--examples/xmlpatterns/schema/schema.pyproject4
-rw-r--r--examples/xmlpatterns/schema/schema.qrc13
-rw-r--r--examples/xmlpatterns/schema/schema.ui71
-rw-r--r--examples/xmlpatterns/schema/schema_rc.py394
-rw-r--r--examples/xmlpatterns/schema/ui_schema.py88
54 files changed, 95 insertions, 3189 deletions
diff --git a/examples/axcontainer/axviewer.py b/examples/axcontainer/axviewer.py
index e9083d8f4..50e50ee1c 100644
--- a/examples/axcontainer/axviewer.py
+++ b/examples/axcontainer/axviewer.py
@@ -43,7 +43,8 @@
import sys
from PySide2.QtAxContainer import QAxSelect, QAxWidget
-from PySide2.QtWidgets import (QAction, QApplication, QDialog,
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import (QApplication, QDialog,
QMainWindow, QMessageBox, QToolBar)
class MainWindow(QMainWindow):
diff --git a/examples/corelib/threads/mandelbrot.py b/examples/corelib/threads/mandelbrot.py
index f0d13dbf5..c0ca70d68 100644
--- a/examples/corelib/threads/mandelbrot.py
+++ b/examples/corelib/threads/mandelbrot.py
@@ -251,7 +251,7 @@ class MandelbrotWidget(QWidget):
painter.save()
painter.translate(newX, newY)
painter.scale(scaleFactor, scaleFactor)
- exposed, _ = painter.matrix().inverted()
+ exposed, _ = painter.transform().inverted()
exposed = exposed.mapRect(self.rect()).adjusted(-1, -1, 1, 1)
painter.drawPixmap(exposed, self.pixmap, exposed)
painter.restore()
@@ -259,7 +259,7 @@ class MandelbrotWidget(QWidget):
text = "Use mouse wheel or the '+' and '-' keys to zoom. Press and " \
"hold left mouse button to scroll."
metrics = painter.fontMetrics()
- textWidth = metrics.width(text)
+ textWidth = metrics.horizontalAdvance(text)
painter.setPen(Qt.NoPen)
painter.setBrush(QColor(0, 0, 0, 127))
diff --git a/examples/corelib/tools/codecs/codecs.py b/examples/corelib/tools/codecs/codecs.py
deleted file mode 100644
index 63e74a60b..000000000
--- a/examples/corelib/tools/codecs/codecs.py
+++ /dev/null
@@ -1,253 +0,0 @@
-
-#############################################################################
-##
-## 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 Qt for Python 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, QtWidgets
-
-
-def codec_name(codec):
- try:
- # Python v3.
- name = str(codec.name(), encoding='ascii')
- except TypeError:
- # Python v2.
- name = str(codec.name())
-
- return name
-
-
-class MainWindow(QtWidgets.QMainWindow):
- def __init__(self):
- super(MainWindow, self).__init__()
-
- self.textEdit = QtWidgets.QTextEdit()
- self.textEdit.setLineWrapMode(QtWidgets.QTextEdit.NoWrap)
- self.setCentralWidget(self.textEdit)
-
- self.codecs = []
- self.findCodecs()
-
- self.previewForm = PreviewForm(self)
- self.previewForm.setCodecList(self.codecs)
-
- self.saveAsActs = []
- self.createActions()
- self.createMenus()
-
- self.setWindowTitle("Codecs")
- self.resize(500, 400)
-
- def open(self):
- fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self)
- if fileName:
- inFile = QtCore.QFile(fileName)
- if not inFile.open(QtCore.QFile.ReadOnly):
- QtWidgets.QMessageBox.warning(self, "Codecs",
- "Cannot read file %s:\n%s" % (fileName, inFile.errorString()))
- return
-
- data = inFile.readAll()
-
- self.previewForm.setEncodedData(data)
- if self.previewForm.exec_():
- self.textEdit.setPlainText(self.previewForm.decodedString())
-
- def save(self):
- fileName = QtWidgets.QFileDialog.getSaveFileName(self)
- if fileName:
- outFile = QtCore.QFile(fileName)
- if not outFile.open(QtCore.QFile.WriteOnly|QtCore.QFile.Text):
- QtWidgets.QMessageBox.warning(self, "Codecs",
- "Cannot write file %s:\n%s" % (fileName, outFile.errorString()))
- return
-
- action = self.sender()
- codecName = action.data()
-
- out = QtCore.QTextStream(outFile)
- out.setCodec(codecName)
- out << self.textEdit.toPlainText()
-
- def about(self):
- QtWidgets.QMessageBox.about(self, "About Codecs",
- "The <b>Codecs</b> example demonstrates how to read and "
- "write files using various encodings.")
-
- def aboutToShowSaveAsMenu(self):
- currentText = self.textEdit.toPlainText()
-
- for action in self.saveAsActs:
- codecName = str(action.data())
- codec = QtCore.QTextCodec.codecForName(codecName)
- action.setVisible(codec and codec.canEncode(currentText))
-
- def findCodecs(self):
- codecMap = []
- iso8859RegExp = QtCore.QRegularExpression('^ISO[- ]8859-([0-9]+).*$')
- assert iso8859RegExp.isValid()
-
- for mib in QtCore.QTextCodec.availableMibs():
- codec = QtCore.QTextCodec.codecForMib(mib)
- sortKey = codec_name(codec).upper()
- rank = 0
-
- if sortKey.startswith('UTF-8'):
- rank = 1
- elif sortKey.startswith('UTF-16'):
- rank = 2
- else:
- match = iso8859RegExp.match(sortKey)
- if match.hasMatch():
- if len(match.captured(1)) == 1:
- rank = 3
- else:
- rank = 4
- else:
- rank = 5
-
- codecMap.append((str(rank) + sortKey, codec))
-
- codecMap.sort()
- self.codecs = [item[-1] for item in codecMap]
-
- def createActions(self):
- self.openAct = QtWidgets.QAction("&Open...", self, shortcut="Ctrl+O",
- triggered=self.open)
-
- for codec in self.codecs:
- name = codec_name(codec)
-
- action = QtWidgets.QAction(name + '...', self, triggered=self.save)
- action.setData(name)
- self.saveAsActs.append(action)
-
- self.exitAct = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+Q",
- triggered=self.close)
-
- self.aboutAct = QtWidgets.QAction("&About", self, triggered=self.about)
-
- self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
- triggered=qApp.aboutQt)
-
- def createMenus(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 = QtWidgets.QMenu("&File", self)
- self.fileMenu.addAction(self.openAct)
- self.fileMenu.addMenu(self.saveAsMenu)
- self.fileMenu.addSeparator()
- self.fileMenu.addAction(self.exitAct)
-
- self.helpMenu = QtWidgets.QMenu("&Help", self)
- self.helpMenu.addAction(self.aboutAct)
- self.helpMenu.addAction(self.aboutQtAct)
-
- self.menuBar().addMenu(self.fileMenu)
- self.menuBar().addSeparator()
- self.menuBar().addMenu(self.helpMenu)
-
-
-class PreviewForm(QtWidgets.QDialog):
- def __init__(self, parent):
- super(PreviewForm, self).__init__(parent)
-
- self.encodingComboBox = QtWidgets.QComboBox()
- encodingLabel = QtWidgets.QLabel("&Encoding:")
- encodingLabel.setBuddy(self.encodingComboBox)
-
- self.textEdit = QtWidgets.QTextEdit()
- self.textEdit.setLineWrapMode(QtWidgets.QTextEdit.NoWrap)
- self.textEdit.setReadOnly(True)
-
- 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 = QtWidgets.QGridLayout()
- mainLayout.addWidget(encodingLabel, 0, 0)
- mainLayout.addWidget(self.encodingComboBox, 0, 1)
- mainLayout.addWidget(self.textEdit, 1, 0, 1, 2)
- mainLayout.addWidget(buttonBox, 2, 0, 1, 2)
- self.setLayout(mainLayout)
-
- self.setWindowTitle("Choose Encoding")
- self.resize(400, 300)
-
- def setCodecList(self, codecs):
- self.encodingComboBox.clear()
- for codec in codecs:
- self.encodingComboBox.addItem(codec_name(codec), codec.mibEnum())
-
- def setEncodedData(self, data):
- self.encodedData = data
- self.updateTextEdit()
-
- def decodedString(self):
- return self.decodedStr
-
- def updateTextEdit(self):
- mib = self.encodingComboBox.itemData(self.encodingComboBox.currentIndex())
- codec = QtCore.QTextCodec.codecForMib(mib)
-
- data = QtCore.QTextStream(self.encodedData)
- data.setAutoDetectUnicode(False)
- data.setCodec(codec)
-
- self.decodedStr = data.readAll()
- self.textEdit.setPlainText(self.decodedStr)
-
-
-if __name__ == '__main__':
-
- import sys
-
- app = QtWidgets.QApplication(sys.argv)
- mainWin = MainWindow()
- mainWin.show()
- sys.exit(app.exec_())
diff --git a/examples/corelib/tools/settingseditor/settingseditor.py b/examples/corelib/tools/settingseditor/settingseditor.py
index a3e50a7c9..121d7cb0e 100644
--- a/examples/corelib/tools/settingseditor/settingseditor.py
+++ b/examples/corelib/tools/settingseditor/settingseditor.py
@@ -47,9 +47,9 @@ import sys
from PySide2.QtCore import (QByteArray, QDate, QDateTime, QDir, QEvent, QPoint,
QRect, QRegularExpression, QSettings, QSize, QTime, QTimer, Qt)
-from PySide2.QtGui import (QColor, QIcon, QIntValidator, QDoubleValidator,
- QRegularExpressionValidator, QValidator)
-from PySide2.QtWidgets import (QAbstractItemView, QAction, QApplication,
+from PySide2.QtGui import (QAction, QColor, QIcon, QIntValidator,
+ QDoubleValidator, QRegularExpressionValidator, QValidator)
+from PySide2.QtWidgets import (QAbstractItemView, QApplication,
QCheckBox, QComboBox, QFileDialog, QDialog, QDialogButtonBox, QGridLayout,
QGroupBox, QHeaderView, QInputDialog, QItemDelegate, QLabel, QLineEdit,
QMainWindow, QMessageBox, QStyle, QSpinBox, QStyleOptionViewItem,
@@ -233,6 +233,16 @@ class MainWindow(QMainWindow):
"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, shortcut="Ctrl+O", triggered=self.openSettings)
+
+ self.openIniFileAct = QtGui.QAction("Open I&NI File...", self,
+ shortcut="Ctrl+N", triggered=self.openIniFile)
+
+ self.openPropertyListAct = QtGui.QAction("Open macOS &Property List...",
+ self, shortcut="Ctrl+P", triggered=self.openPropertyList)
+
def create_actions(self):
self.open_settings_action = QAction("&Open Application Settings...",
self, shortcut="Ctrl+O", triggered=self.open_settings)
diff --git a/examples/external/matplotlib/widget_3dplot.py b/examples/external/matplotlib/widget_3dplot.py
index b96405661..6f47da31b 100644
--- a/examples/external/matplotlib/widget_3dplot.py
+++ b/examples/external/matplotlib/widget_3dplot.py
@@ -45,8 +45,8 @@ from matplotlib.backends.backend_qt5agg import FigureCanvas
from matplotlib.figure import Figure
from mpl_toolkits.mplot3d import axes3d
from PySide2.QtCore import Qt, Slot
-from PySide2.QtGui import QKeySequence
-from PySide2.QtWidgets import (QAction, QApplication, QComboBox, QHBoxLayout,
+from PySide2.QtGui import QAction, QKeySequence
+from PySide2.QtWidgets import (QApplication, QComboBox, QHBoxLayout,
QHeaderView, QLabel, QMainWindow, QSlider,
QTableWidget, QTableWidgetItem, QVBoxLayout,
QWidget)
diff --git a/examples/external/opencv/webcam_pattern_detection.py b/examples/external/opencv/webcam_pattern_detection.py
index 553261615..664ba2111 100644
--- a/examples/external/opencv/webcam_pattern_detection.py
+++ b/examples/external/opencv/webcam_pattern_detection.py
@@ -44,8 +44,8 @@ import time
import cv2
from PySide2.QtCore import Qt, QThread, Signal, Slot
-from PySide2.QtGui import QImage, QKeySequence, QPixmap
-from PySide2.QtWidgets import (QAction, QApplication, QComboBox, QGroupBox,
+from PySide2.QtGui import QAction, QImage, QKeySequence, QPixmap
+from PySide2.QtWidgets import (QApplication, QComboBox, QGroupBox,
QHBoxLayout, QLabel, QMainWindow, QPushButton,
QSizePolicy, QVBoxLayout, QWidget)
diff --git a/examples/external/scikit/staining_colors_separation.py b/examples/external/scikit/staining_colors_separation.py
index 051b2bc25..d21453927 100644
--- a/examples/external/scikit/staining_colors_separation.py
+++ b/examples/external/scikit/staining_colors_separation.py
@@ -45,8 +45,8 @@ from matplotlib.backends.backend_qt5agg import FigureCanvas
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.figure import Figure
from PySide2.QtCore import Qt, Slot
-from PySide2.QtGui import QKeySequence
-from PySide2.QtWidgets import (QAction, QApplication, QHBoxLayout, QLabel,
+from PySide2.QtGui import QAction, QKeySequence
+from PySide2.QtWidgets import (QApplication, QHBoxLayout, QLabel,
QMainWindow, QPushButton, QSizePolicy,
QVBoxLayout, QWidget)
from skimage import data
diff --git a/examples/multimedia/camera.py b/examples/multimedia/camera.py
index d58b526d9..644b5340c 100644
--- a/examples/multimedia/camera.py
+++ b/examples/multimedia/camera.py
@@ -43,9 +43,9 @@
import os, sys
from PySide2.QtCore import QDate, QDir, QStandardPaths, Qt, QUrl
-from PySide2.QtGui import QGuiApplication, QDesktopServices, QIcon
+from PySide2.QtGui import QAction, QGuiApplication, QDesktopServices, QIcon
from PySide2.QtGui import QImage, QPixmap
-from PySide2.QtWidgets import (QAction, QApplication, QHBoxLayout, QLabel,
+from PySide2.QtWidgets import (QApplication, QHBoxLayout, QLabel,
QMainWindow, QPushButton, QTabWidget, QToolBar, QVBoxLayout, QWidget)
from PySide2.QtMultimedia import QCamera, QCameraImageCapture, QCameraInfo
from PySide2.QtMultimediaWidgets import QCameraViewfinder
diff --git a/examples/multimedia/player.py b/examples/multimedia/player.py
index cb70e50d6..762d26b7e 100644
--- a/examples/multimedia/player.py
+++ b/examples/multimedia/player.py
@@ -43,8 +43,8 @@
import sys
from PySide2.QtCore import QStandardPaths, Qt
-from PySide2.QtGui import QIcon, QKeySequence
-from PySide2.QtWidgets import (QAction, QApplication, QDialog, QFileDialog,
+from PySide2.QtGui import QAction, QIcon, QKeySequence
+from PySide2.QtWidgets import (QApplication, QDialog, QFileDialog,
QMainWindow, QSlider, QStyle, QToolBar)
from PySide2.QtMultimedia import QMediaPlayer, QMediaPlaylist
from PySide2.QtMultimediaWidgets import QVideoWidget
@@ -137,7 +137,7 @@ class MainWindow(QMainWindow):
if self.player.position() <= 5000:
self.playlist.previous()
else:
- player.setPosition(0)
+ self.player.setPosition(0)
def updateButtons(self, state):
mediaCount = self.playlist.mediaCount()
diff --git a/examples/network/fortuneclient.py b/examples/network/fortuneclient.py
index c774973c0..00247eee0 100644
--- a/examples/network/fortuneclient.py
+++ b/examples/network/fortuneclient.py
@@ -83,7 +83,7 @@ class Client(QtWidgets.QDialog):
self.getFortuneButton.clicked.connect(self.requestNewFortune)
quitButton.clicked.connect(self.close)
self.tcpSocket.readyRead.connect(self.readFortune)
- self.tcpSocket.error.connect(self.displayError)
+ self.tcpSocket.errorOccurred.connect(self.displayError)
mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(hostLabel, 0, 0)
diff --git a/examples/opengl/2dpainting.py b/examples/opengl/2dpainting.py
deleted file mode 100644
index 5b3ba6183..000000000
--- a/examples/opengl/2dpainting.py
+++ /dev/null
@@ -1,172 +0,0 @@
-
-############################################################################
-##
-## 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 Qt for Python 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 opengl/legacy/2dpainting example from Qt v5.x"""
-
-import sys
-from PySide2.QtCore import *
-from PySide2.QtGui import *
-from PySide2.QtWidgets import *
-from PySide2.QtOpenGL import *
-
-try:
- from OpenGL import GL
-except ImportError:
- app = QApplication(sys.argv)
- messageBox = QMessageBox(QMessageBox.Critical, "OpenGL 2dpainting",
- "PyOpenGL must be installed to run this example.",
- QMessageBox.Close)
- messageBox.setDetailedText("Run:\npip install PyOpenGL PyOpenGL_accelerate")
- messageBox.exec_()
- sys.exit(1)
-
-
-class Helper:
- def __init__(self):
- gradient = QLinearGradient(QPointF(50, -20), QPointF(80, 20))
- gradient.setColorAt(0.0, Qt.white)
- gradient.setColorAt(1.0, QColor(0xa6, 0xce, 0x39))
-
- self.background = QBrush(QColor(64, 32, 64))
- self.circleBrush = QBrush(gradient)
- self.circlePen = QPen(Qt.black)
- self.circlePen.setWidth(1)
- self.textPen = QPen(Qt.white)
- self.textFont = QFont()
- self.textFont.setPixelSize(50)
-
- def paint(self, painter, event, elapsed):
- painter.fillRect(event.rect(), self.background)
- painter.translate(100, 100)
-
- painter.save()
- painter.setBrush(self.circleBrush)
- painter.setPen(self.circlePen)
- painter.rotate(elapsed * 0.030)
-
- r = elapsed/1000.0
- n = 30
- for i in range(n):
- painter.rotate(30)
- radius = 0 + 120.0*((i+r)/n)
- circleRadius = 1 + ((i+r)/n)*20
- painter.drawEllipse(QRectF(radius, -circleRadius,
- circleRadius*2, circleRadius*2))
-
- painter.restore()
-
- painter.setPen(self.textPen)
- painter.setFont(self.textFont)
- painter.drawText(QRect(-50, -50, 100, 100), Qt.AlignCenter, "Qt")
-
-
-class Widget(QWidget):
- def __init__(self, helper, parent = None):
- QWidget.__init__(self, parent)
-
- self.helper = helper
- self.elapsed = 0
- self.setFixedSize(200, 200)
-
- def animate(self):
- self.elapsed = (self.elapsed + self.sender().interval()) % 1000
- self.repaint()
-
- def paintEvent(self, event):
- painter = QPainter()
- painter.begin(self)
- painter.setRenderHint(QPainter.Antialiasing)
- self.helper.paint(painter, event, self.elapsed)
- painter.end()
-
-
-class GLWidget(QGLWidget):
- def __init__(self, helper, parent = None):
- QGLWidget.__init__(self, QGLFormat(QGL.SampleBuffers), parent)
-
- self.helper = helper
- self.elapsed = 0
- self.setFixedSize(200, 200)
-
- def animate(self):
- self.elapsed = (self.elapsed + self.sender().interval()) % 1000
- self.repaint()
-
- def paintEvent(self, event):
- painter = QPainter()
- painter.begin(self)
- self.helper.paint(painter, event, self.elapsed)
- painter.end()
-
-
-class Window(QWidget):
- def __init__(self, parent = None):
- QWidget.__init__(self, parent)
-
- helper = Helper()
- native = Widget(helper, self)
- openGL = GLWidget(helper, self)
- nativeLabel = QLabel(self.tr("Native"))
- nativeLabel.setAlignment(Qt.AlignHCenter)
- openGLLabel = QLabel(self.tr("OpenGL"))
- openGLLabel.setAlignment(Qt.AlignHCenter)
-
- layout = QGridLayout()
- layout.addWidget(native, 0, 0)
- layout.addWidget(openGL, 0, 1)
- layout.addWidget(nativeLabel, 1, 0)
- layout.addWidget(openGLLabel, 1, 1)
- self.setLayout(layout)
-
- timer = QTimer(self)
- self.connect(timer, SIGNAL("timeout()"), native.animate)
- self.connect(timer, SIGNAL("timeout()"), openGL.animate)
- timer.start(50)
-
- self.setWindowTitle(self.tr("2D Painting on Native and OpenGL Widgets"))
-
-
-if __name__ == '__main__':
- app = QApplication(sys.argv)
- window = Window()
- window.show()
- sys.exit(app.exec_())
diff --git a/examples/opengl/contextinfo.py b/examples/opengl/contextinfo.py
index a963b8952..fce400e70 100644
--- a/examples/opengl/contextinfo.py
+++ b/examples/opengl/contextinfo.py
@@ -48,8 +48,9 @@ from textwrap import dedent
from PySide2.QtCore import QCoreApplication, QLibraryInfo, QSize, QTimer, Qt
-from PySide2.QtGui import (QMatrix4x4, QOpenGLBuffer, QOpenGLContext, QOpenGLShader,
- QOpenGLShaderProgram, QOpenGLVertexArrayObject, QSurfaceFormat, QWindow)
+from PySide2.QtGui import (QMatrix4x4, QOpenGLContext, QSurfaceFormat, QWindow)
+from PySide2.QtOpenGL import (QOpenGLBuffer, QOpenGLShader,
+ QOpenGLShaderProgram, QOpenGLVertexArrayObject)
from PySide2.QtWidgets import (QApplication, QHBoxLayout, QMessageBox, QPlainTextEdit,
QWidget)
from PySide2.support import VoidPtr
diff --git a/examples/opengl/grabber.py b/examples/opengl/grabber.py
deleted file mode 100644
index 4c8f9a0d2..000000000
--- a/examples/opengl/grabber.py
+++ /dev/null
@@ -1,437 +0,0 @@
-
-############################################################################
-##
-## 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 Qt for Python 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 opengl/legacy/grabber example from Qt v5.x"""
-
-import sys
-import math
-
-from PySide2 import QtCore, QtGui, QtWidgets, QtOpenGL
-
-try:
- from OpenGL.GL import *
-except ImportError:
- app = QtWidgets.QApplication(sys.argv)
- messageBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, "OpenGL grabber",
- "PyOpenGL must be installed to run this example.",
- QtWidgets.QMessageBox.Close)
- messageBox.setDetailedText("Run:\npip install PyOpenGL PyOpenGL_accelerate")
- messageBox.exec_()
- sys.exit(1)
-
-
-class GLWidget(QtOpenGL.QGLWidget):
- xRotationChanged = QtCore.Signal(int)
- yRotationChanged = QtCore.Signal(int)
- zRotationChanged = QtCore.Signal(int)
-
- def __init__(self, parent=None):
- super(GLWidget, self).__init__(parent)
-
- self.gear1 = 0
- self.gear2 = 0
- self.gear3 = 0
- self.xRot = 0
- self.yRot = 0
- self.zRot = 0
- self.gear1Rot = 0
-
- timer = QtCore.QTimer(self)
- timer.timeout.connect(self.advanceGears)
- timer.start(20)
-
- def freeResources(self):
- self.makeCurrent()
- glDeleteLists(self.gear1, 1)
- glDeleteLists(self.gear2, 1)
- glDeleteLists(self.gear3, 1)
-
- def setXRotation(self, angle):
- self.normalizeAngle(angle)
-
- if angle != self.xRot:
- self.xRot = angle
- self.xRotationChanged.emit(angle)
- self.updateGL()
-
- def setYRotation(self, angle):
- self.normalizeAngle(angle)
-
- if angle != self.yRot:
- self.yRot = angle
- self.yRotationChanged.emit(angle)
- self.updateGL()
-
- def setZRotation(self, angle):
- self.normalizeAngle(angle)
-
- if angle != self.zRot:
- self.zRot = angle
- self.zRotationChanged.emit(angle)
- self.updateGL()
-
- def initializeGL(self):
- lightPos = (5.0, 5.0, 10.0, 1.0)
- reflectance1 = (0.8, 0.1, 0.0, 1.0)
- reflectance2 = (0.0, 0.8, 0.2, 1.0)
- reflectance3 = (0.2, 0.2, 1.0, 1.0)
-
- glLightfv(GL_LIGHT0, GL_POSITION, lightPos)
- glEnable(GL_LIGHTING)
- glEnable(GL_LIGHT0)
- glEnable(GL_DEPTH_TEST)
-
- self.gear1 = self.makeGear(reflectance1, 1.0, 4.0, 1.0, 0.7, 20)
- self.gear2 = self.makeGear(reflectance2, 0.5, 2.0, 2.0, 0.7, 10)
- self.gear3 = self.makeGear(reflectance3, 1.3, 2.0, 0.5, 0.7, 10)
-
- glEnable(GL_NORMALIZE)
- glClearColor(0.0, 0.0, 0.0, 1.0)
-
- def paintGL(self):
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
-
- glPushMatrix()
- glRotated(self.xRot / 16.0, 1.0, 0.0, 0.0)
- glRotated(self.yRot / 16.0, 0.0, 1.0, 0.0)
- glRotated(self.zRot / 16.0, 0.0, 0.0, 1.0)
-
- self.drawGear(self.gear1, -3.0, -2.0, 0.0, self.gear1Rot / 16.0)
- self.drawGear(self.gear2, +3.1, -2.0, 0.0,
- -2.0 * (self.gear1Rot / 16.0) - 9.0)
-
- glRotated(+90.0, 1.0, 0.0, 0.0)
- self.drawGear(self.gear3, -3.1, -1.8, -2.2,
- +2.0 * (self.gear1Rot / 16.0) - 2.0)
-
- glPopMatrix()
-
- def resizeGL(self, width, height):
- side = min(width, height)
- if side < 0:
- return
-
- glViewport(int((width - side) / 2), int((height - side) / 2), side, side)
-
- glMatrixMode(GL_PROJECTION)
- glLoadIdentity()
- glFrustum(-1.0, +1.0, -1.0, 1.0, 5.0, 60.0)
- glMatrixMode(GL_MODELVIEW)
- glLoadIdentity()
- glTranslated(0.0, 0.0, -40.0)
-
- def mousePressEvent(self, event):
- self.lastPos = event.pos()
-
- def mouseMoveEvent(self, event):
- dx = event.x() - self.lastPos.x()
- dy = event.y() - self.lastPos.y()
-
- if event.buttons() & QtCore.Qt.LeftButton:
- self.setXRotation(self.xRot + 8 * dy)
- self.setYRotation(self.yRot + 8 * dx)
- elif event.buttons() & QtCore.Qt.RightButton:
- self.setXRotation(self.xRot + 8 * dy)
- self.setZRotation(self.zRot + 8 * dx)
-
- self.lastPos = event.pos()
-
- def advanceGears(self):
- self.gear1Rot += 2 * 16
- self.updateGL()
-
- def xRotation(self):
- return self.xRot
-
- def yRotation(self):
- return self.yRot
-
- def zRotation(self):
- return self.zRot
-
- def makeGear(self, reflectance, innerRadius, outerRadius, thickness, toothSize, toothCount):
- list = glGenLists(1)
- glNewList(list, GL_COMPILE)
- glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, reflectance)
-
- r0 = innerRadius
- r1 = outerRadius - toothSize / 2.0
- r2 = outerRadius + toothSize / 2.0
- delta = (2.0 * math.pi / toothCount) / 4.0
- z = thickness / 2.0
-
- glShadeModel(GL_FLAT)
-
- for i in range(2):
- if i == 0:
- sign = +1.0
- else:
- sign = -1.0
-
- glNormal3d(0.0, 0.0, sign)
-
- glBegin(GL_QUAD_STRIP)
-
- for j in range(toothCount+1):
- angle = 2.0 * math.pi * j / toothCount
- glVertex3d(r0 * math.cos(angle), r0 * math.sin(angle), sign * z)
- glVertex3d(r1 * math.cos(angle), r1 * math.sin(angle), sign * z)
- glVertex3d(r0 * math.cos(angle), r0 * math.sin(angle), sign * z)
- glVertex3d(r1 * math.cos(angle + 3 * delta), r1 * math.sin(angle + 3 * delta), sign * z)
-
- glEnd()
-
- glBegin(GL_QUADS)
-
- for j in range(toothCount):
- angle = 2.0 * math.pi * j / toothCount
- glVertex3d(r1 * math.cos(angle), r1 * math.sin(angle), sign * z)
- glVertex3d(r2 * math.cos(angle + delta), r2 * math.sin(angle + delta), sign * z)
- glVertex3d(r2 * math.cos(angle + 2 * delta), r2 * math.sin(angle + 2 * delta), sign * z)
- glVertex3d(r1 * math.cos(angle + 3 * delta), r1 * math.sin(angle + 3 * delta), sign * z)
-
- glEnd()
-
- glBegin(GL_QUAD_STRIP)
-
- for i in range(toothCount):
- for j in range(2):
- angle = 2.0 * math.pi * (i + (j / 2.0)) / toothCount
- s1 = r1
- s2 = r2
-
- if j == 1:
- s1, s2 = s2, s1
-
- glNormal3d(math.cos(angle), math.sin(angle), 0.0)
- glVertex3d(s1 * math.cos(angle), s1 * math.sin(angle), +z)
- glVertex3d(s1 * math.cos(angle), s1 * math.sin(angle), -z)
-
- glNormal3d(s2 * math.sin(angle + delta) - s1 * math.sin(angle), s1 * math.cos(angle) - s2 * math.cos(angle + delta), 0.0)
- glVertex3d(s2 * math.cos(angle + delta), s2 * math.sin(angle + delta), +z)
- glVertex3d(s2 * math.cos(angle + delta), s2 * math.sin(angle + delta), -z)
-
- glVertex3d(r1, 0.0, +z)
- glVertex3d(r1, 0.0, -z)
- glEnd()
-
- glShadeModel(GL_SMOOTH)
-
- glBegin(GL_QUAD_STRIP)
-
- for i in range(toothCount+1):
- angle = i * 2.0 * math.pi / toothCount
- glNormal3d(-math.cos(angle), -math.sin(angle), 0.0)
- glVertex3d(r0 * math.cos(angle), r0 * math.sin(angle), +z)
- glVertex3d(r0 * math.cos(angle), r0 * math.sin(angle), -z)
-
- glEnd()
-
- glEndList()
-
- return list
-
- def drawGear(self, gear, dx, dy, dz, angle):
- glPushMatrix()
- glTranslated(dx, dy, dz)
- glRotated(angle, 0.0, 0.0, 1.0)
- glCallList(gear)
- glPopMatrix()
-
- def normalizeAngle(self, angle):
- while (angle < 0):
- angle += 360 * 16
-
- while (angle > 360 * 16):
- angle -= 360 * 16
-
-
-class MainWindow(QtWidgets.QMainWindow):
- def __init__(self):
- super(MainWindow, self).__init__()
-
- centralWidget = QtWidgets.QWidget()
- self.setCentralWidget(centralWidget)
-
- self.glWidget = GLWidget()
- self.pixmapLabel = QtWidgets.QLabel()
-
- self.glWidgetArea = QtWidgets.QScrollArea()
- self.glWidgetArea.setWidget(self.glWidget)
- self.glWidgetArea.setWidgetResizable(True)
- self.glWidgetArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
- self.glWidgetArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
- self.glWidgetArea.setSizePolicy(QtWidgets.QSizePolicy.Ignored,
- QtWidgets.QSizePolicy.Ignored)
- self.glWidgetArea.setMinimumSize(50, 50)
-
- self.pixmapLabelArea = QtWidgets.QScrollArea()
- self.pixmapLabelArea.setWidget(self.pixmapLabel)
- self.pixmapLabelArea.setSizePolicy(QtWidgets.QSizePolicy.Ignored,
- QtWidgets.QSizePolicy.Ignored)
- self.pixmapLabelArea.setMinimumSize(50, 50)
-
- xSlider = self.createSlider(self.glWidget.xRotationChanged,
- self.glWidget.setXRotation)
- ySlider = self.createSlider(self.glWidget.yRotationChanged,
- self.glWidget.setYRotation)
- zSlider = self.createSlider(self.glWidget.zRotationChanged,
- self.glWidget.setZRotation)
-
- self.createActions()
- self.createMenus()
-
- centralLayout = QtWidgets.QGridLayout()
- centralLayout.addWidget(self.glWidgetArea, 0, 0)
- centralLayout.addWidget(self.pixmapLabelArea, 0, 1)
- centralLayout.addWidget(xSlider, 1, 0, 1, 2)
- centralLayout.addWidget(ySlider, 2, 0, 1, 2)
- centralLayout.addWidget(zSlider, 3, 0, 1, 2)
- centralWidget.setLayout(centralLayout)
-
- xSlider.setValue(15 * 16)
- ySlider.setValue(345 * 16)
- zSlider.setValue(0 * 16)
-
- self.setWindowTitle("Grabber")
- self.resize(400, 300)
-
- def renderIntoPixmap(self):
- size = self.getSize()
-
- if size.isValid():
- pixmap = self.glWidget.renderPixmap(size.width(), size.height())
- self.setPixmap(pixmap)
-
- def grabFrameBuffer(self):
- image = self.glWidget.grabFrameBuffer()
- self.setPixmap(QtGui.QPixmap.fromImage(image))
-
- def clearPixmap(self):
- self.setPixmap(QtGui.QPixmap())
-
- def about(self):
- QtWidgets.QMessageBox.about(self, "About Grabber",
- "The <b>Grabber</b> example demonstrates two approaches for "
- "rendering OpenGL into a Qt pixmap.")
-
- def createActions(self):
- self.renderIntoPixmapAct = QtWidgets.QAction("&Render into Pixmap...",
- self, shortcut="Ctrl+R", triggered=self.renderIntoPixmap)
-
- self.grabFrameBufferAct = QtWidgets.QAction("&Grab Frame Buffer", self,
- shortcut="Ctrl+G", triggered=self.grabFrameBuffer)
-
- self.clearPixmapAct = QtWidgets.QAction("&Clear Pixmap", self,
- shortcut="Ctrl+L", triggered=self.clearPixmap)
-
- self.exitAct = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+Q",
- triggered=self.close)
-
- self.aboutAct = QtWidgets.QAction("&About", self, triggered=self.about)
-
- self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
- triggered=qApp.aboutQt)
-
- def createMenus(self):
- self.fileMenu = self.menuBar().addMenu("&File")
- self.fileMenu.addAction(self.renderIntoPixmapAct)
- self.fileMenu.addAction(self.grabFrameBufferAct)
- self.fileMenu.addAction(self.clearPixmapAct)
- self.fileMenu.addSeparator()
- self.fileMenu.addAction(self.exitAct)
-
- self.helpMenu = self.menuBar().addMenu("&Help")
- self.helpMenu.addAction(self.aboutAct)
- self.helpMenu.addAction(self.aboutQtAct)
-
- def createSlider(self, changedSignal, setterSlot):
- slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
- slider.setRange(0, 360 * 16)
- slider.setSingleStep(16)
- slider.setPageStep(15 * 16)
- slider.setTickInterval(15 * 16)
- slider.setTickPosition(QtWidgets.QSlider.TicksRight)
-
- slider.valueChanged.connect(setterSlot)
- changedSignal.connect(slider.setValue)
-
- return slider
-
- def setPixmap(self, pixmap):
- self.pixmapLabel.setPixmap(pixmap)
- size = pixmap.size()
-
- if size - QtCore.QSize(1, 0) == self.pixmapLabelArea.maximumViewportSize():
- size -= QtCore.QSize(1, 0)
-
- self.pixmapLabel.resize(size)
-
- def getSize(self):
- text, ok = QtWidgets.QInputDialog.getText(self, "Grabber",
- "Enter pixmap size:", QtWidgets.QLineEdit.Normal,
- "%d x %d" % (self.glWidget.width(), self.glWidget.height()))
-
- if not ok:
- return QtCore.QSize()
-
- regExp = QtCore.QRegularExpression("([0-9]+) *x *([0-9]+)")
- assert regExp.isValid()
-
- match = regExp.match(text)
- if match.hasMatch():
- width = int(match.captured(1))
- height = int(match.captured(2))
- if width > 0 and width < 2048 and height > 0 and height < 2048:
- return QtCore.QSize(width, height)
-
- return self.glWidget.size()
-
-
-if __name__ == '__main__':
-
- app = QtWidgets.QApplication(sys.argv)
- mainWin = MainWindow()
- mainWin.show()
- res = app.exec_()
- mainWin.glWidget.freeResources()
- sys.exit(res)
diff --git a/examples/opengl/hellogl.py b/examples/opengl/hellogl.py
deleted file mode 100644
index f3aa73ad5..000000000
--- a/examples/opengl/hellogl.py
+++ /dev/null
@@ -1,287 +0,0 @@
-
-############################################################################
-##
-## 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 Qt for Python 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 opengl/legacy/hellogl example from Qt v5.x"""
-
-import sys
-import math
-from PySide2 import QtCore, QtGui, QtWidgets, QtOpenGL
-
-try:
- from OpenGL import GL
-except ImportError:
- app = QtWidgets.QApplication(sys.argv)
- messageBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, "OpenGL hellogl",
- "PyOpenGL must be installed to run this example.",
- QtWidgets.QMessageBox.Close)
- messageBox.setDetailedText("Run:\npip install PyOpenGL PyOpenGL_accelerate")
- messageBox.exec_()
- sys.exit(1)
-
-
-class Window(QtWidgets.QWidget):
- def __init__(self, parent=None):
- QtWidgets.QWidget.__init__(self, parent)
-
- self.glWidget = GLWidget()
-
- self.xSlider = self.createSlider(QtCore.SIGNAL("xRotationChanged(int)"),
- self.glWidget.setXRotation)
- self.ySlider = self.createSlider(QtCore.SIGNAL("yRotationChanged(int)"),
- self.glWidget.setYRotation)
- self.zSlider = self.createSlider(QtCore.SIGNAL("zRotationChanged(int)"),
- self.glWidget.setZRotation)
-
- mainLayout = QtWidgets.QHBoxLayout()
- mainLayout.addWidget(self.glWidget)
- mainLayout.addWidget(self.xSlider)
- mainLayout.addWidget(self.ySlider)
- mainLayout.addWidget(self.zSlider)
- self.setLayout(mainLayout)
-
- self.xSlider.setValue(170 * 16)
- self.ySlider.setValue(160 * 16)
- self.zSlider.setValue(90 * 16)
-
- self.setWindowTitle(self.tr("Hello GL"))
-
- def createSlider(self, changedSignal, setterSlot):
- slider = QtWidgets.QSlider(QtCore.Qt.Vertical)
-
- slider.setRange(0, 360 * 16)
- slider.setSingleStep(16)
- slider.setPageStep(15 * 16)
- slider.setTickInterval(15 * 16)
- slider.setTickPosition(QtWidgets.QSlider.TicksRight)
-
- self.glWidget.connect(slider, QtCore.SIGNAL("valueChanged(int)"), setterSlot)
- self.connect(self.glWidget, changedSignal, slider, QtCore.SLOT("setValue(int)"))
-
- return slider
-
-
-class GLWidget(QtOpenGL.QGLWidget):
- xRotationChanged = QtCore.Signal(int)
- yRotationChanged = QtCore.Signal(int)
- zRotationChanged = QtCore.Signal(int)
-
- def __init__(self, parent=None):
- QtOpenGL.QGLWidget.__init__(self, parent)
-
- self.object = 0
- self.xRot = 0
- self.yRot = 0
- self.zRot = 0
-
- self.lastPos = QtCore.QPoint()
-
- self.trolltechGreen = QtGui.QColor.fromCmykF(0.40, 0.0, 1.0, 0.0)
- self.trolltechPurple = QtGui.QColor.fromCmykF(0.39, 0.39, 0.0, 0.0)
-
- def xRotation(self):
- return self.xRot
-
- def yRotation(self):
- return self.yRot
-
- def zRotation(self):
- return self.zRot
-
- def minimumSizeHint(self):
- return QtCore.QSize(50, 50)
-
- def sizeHint(self):
- return QtCore.QSize(400, 400)
-
- def setXRotation(self, angle):
- angle = self.normalizeAngle(angle)
- if angle != self.xRot:
- self.xRot = angle
- self.emit(QtCore.SIGNAL("xRotationChanged(int)"), angle)
- self.updateGL()
-
- def setYRotation(self, angle):
- angle = self.normalizeAngle(angle)
- if angle != self.yRot:
- self.yRot = angle
- self.emit(QtCore.SIGNAL("yRotationChanged(int)"), angle)
- self.updateGL()
-
- def setZRotation(self, angle):
- angle = self.normalizeAngle(angle)
- if angle != self.zRot:
- self.zRot = angle
- self.emit(QtCore.SIGNAL("zRotationChanged(int)"), angle)
- self.updateGL()
-
- def initializeGL(self):
- self.qglClearColor(self.trolltechPurple.darker())
- self.object = self.makeObject()
- GL.glShadeModel(GL.GL_FLAT)
- GL.glEnable(GL.GL_DEPTH_TEST)
- GL.glEnable(GL.GL_CULL_FACE)
-
- def paintGL(self):
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
- GL.glLoadIdentity()
- GL.glTranslated(0.0, 0.0, -10.0)
- GL.glRotated(self.xRot / 16.0, 1.0, 0.0, 0.0)
- GL.glRotated(self.yRot / 16.0, 0.0, 1.0, 0.0)
- GL.glRotated(self.zRot / 16.0, 0.0, 0.0, 1.0)
- GL.glCallList(self.object)
-
- def resizeGL(self, width, height):
- side = min(width, height)
- GL.glViewport(int((width - side) / 2),int((height - side) / 2), side, side)
-
- GL.glMatrixMode(GL.GL_PROJECTION)
- GL.glLoadIdentity()
- GL.glOrtho(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0)
- GL.glMatrixMode(GL.GL_MODELVIEW)
-
- def mousePressEvent(self, event):
- self.lastPos = QtCore.QPoint(event.pos())
-
- def mouseMoveEvent(self, event):
- dx = event.x() - self.lastPos.x()
- dy = event.y() - self.lastPos.y()
-
- if event.buttons() & QtCore.Qt.LeftButton:
- self.setXRotation(self.xRot + 8 * dy)
- self.setYRotation(self.yRot + 8 * dx)
- elif event.buttons() & QtCore.Qt.RightButton:
- self.setXRotation(self.xRot + 8 * dy)
- self.setZRotation(self.zRot + 8 * dx)
-
- self.lastPos = QtCore.QPoint(event.pos())
-
- def makeObject(self):
- genList = GL.glGenLists(1)
- GL.glNewList(genList, GL.GL_COMPILE)
-
- GL.glBegin(GL.GL_QUADS)
-
- x1 = +0.06
- y1 = -0.14
- x2 = +0.14
- y2 = -0.06
- x3 = +0.08
- y3 = +0.00
- x4 = +0.30
- y4 = +0.22
-
- self.quad(x1, y1, x2, y2, y2, x2, y1, x1)
- self.quad(x3, y3, x4, y4, y4, x4, y3, x3)
-
- self.extrude(x1, y1, x2, y2)
- self.extrude(x2, y2, y2, x2)
- self.extrude(y2, x2, y1, x1)
- self.extrude(y1, x1, x1, y1)
- self.extrude(x3, y3, x4, y4)
- self.extrude(x4, y4, y4, x4)
- self.extrude(y4, x4, y3, x3)
-
- Pi = 3.14159265358979323846
- NumSectors = 200
-
- for i in range(NumSectors):
- angle1 = (i * 2 * Pi) / NumSectors
- x5 = 0.30 * math.sin(angle1)
- y5 = 0.30 * math.cos(angle1)
- x6 = 0.20 * math.sin(angle1)
- y6 = 0.20 * math.cos(angle1)
-
- angle2 = ((i + 1) * 2 * Pi) / NumSectors
- x7 = 0.20 * math.sin(angle2)
- y7 = 0.20 * math.cos(angle2)
- x8 = 0.30 * math.sin(angle2)
- y8 = 0.30 * math.cos(angle2)
-
- self.quad(x5, y5, x6, y6, x7, y7, x8, y8)
-
- self.extrude(x6, y6, x7, y7)
- self.extrude(x8, y8, x5, y5)
-
- GL.glEnd()
- GL.glEndList()
-
- return genList
-
- def quad(self, x1, y1, x2, y2, x3, y3, x4, y4):
- self.qglColor(self.trolltechGreen)
-
- GL.glVertex3d(x1, y1, +0.05)
- GL.glVertex3d(x2, y2, +0.05)
- GL.glVertex3d(x3, y3, +0.05)
- GL.glVertex3d(x4, y4, +0.05)
-
- GL.glVertex3d(x4, y4, -0.05)
- GL.glVertex3d(x3, y3, -0.05)
- GL.glVertex3d(x2, y2, -0.05)
- GL.glVertex3d(x1, y1, -0.05)
-
- def extrude(self, x1, y1, x2, y2):
- self.qglColor(self.trolltechGreen.darker(250 + int(100 * x1)))
-
- GL.glVertex3d(x1, y1, -0.05)
- GL.glVertex3d(x2, y2, -0.05)
- GL.glVertex3d(x2, y2, +0.05)
- GL.glVertex3d(x1, y1, +0.05)
-
- def normalizeAngle(self, angle):
- while angle < 0:
- angle += 360 * 16
- while angle > 360 * 16:
- angle -= 360 * 16
- return angle
-
- def freeResources(self):
- self.makeCurrent()
- GL.glDeleteLists(self.object, 1)
-
-if __name__ == '__main__':
- app = QtWidgets.QApplication(sys.argv)
- window = Window()
- window.show()
- res = app.exec_()
- window.glWidget.freeResources()
- sys.exit(res)
diff --git a/examples/opengl/hellogl2.py b/examples/opengl/hellogl2.py
index ad3562f0b..b12a7b275 100644
--- a/examples/opengl/hellogl2.py
+++ b/examples/opengl/hellogl2.py
@@ -47,10 +47,14 @@ import math
import numpy
import ctypes
from PySide2.QtCore import QCoreApplication, Signal, SIGNAL, SLOT, Qt, QSize, QPoint
-from PySide2.QtGui import (QVector3D, QOpenGLFunctions, QOpenGLVertexArrayObject, QOpenGLBuffer,
- QOpenGLShaderProgram, QMatrix4x4, QOpenGLShader, QOpenGLContext, QSurfaceFormat)
-from PySide2.QtWidgets import (QApplication, QWidget, QMessageBox, QHBoxLayout, QSlider,
- QOpenGLWidget)
+from PySide2.QtGui import (QVector3D, QOpenGLFunctions,
+ QMatrix4x4, QOpenGLContext, QSurfaceFormat)
+from PySide2.QtOpenGL import (QOpenGLVertexArrayObject, QOpenGLBuffer,
+ QOpenGLShaderProgram, QOpenGLShader)
+from PySide2.QtWidgets import (QApplication, QWidget, QMessageBox, QHBoxLayout,
+ QSlider)
+from PySide2.QtOpenGLWidgets import QOpenGLWidget
+
from shiboken2 import VoidPtr
try:
diff --git a/examples/opengl/opengl.pyproject b/examples/opengl/opengl.pyproject
index 12f435daf..20b289d7b 100644
--- a/examples/opengl/opengl.pyproject
+++ b/examples/opengl/opengl.pyproject
@@ -1,5 +1,3 @@
{
- "files": ["grabber.py", "samplebuffers.py", "hellogl.py",
- "hellogl2.py", "contextinfo.py", "2dpainting.py",
- "overpainting.py"]
+ "files": ["hellogl2.py", "contextinfo.py"]
}
diff --git a/examples/opengl/overpainting.py b/examples/opengl/overpainting.py
deleted file mode 100644
index 786337f88..000000000
--- a/examples/opengl/overpainting.py
+++ /dev/null
@@ -1,385 +0,0 @@
-
-############################################################################
-##
-## 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 Qt for Python 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 opengl/legacy/overpainting example from Qt v5.x"""
-
-import sys
-import math, random
-from PySide2.QtCore import *
-from PySide2.QtGui import *
-from PySide2.QtWidgets import *
-from PySide2.QtOpenGL import *
-
-try:
- from OpenGL.GL import *
-except ImportError:
- app = QApplication(sys.argv)
- messageBox = QMessageBox(QMessageBox.Critical, "OpenGL overpainting",
- "PyOpenGL must be installed to run this example.",
- QMessageBox.Close)
- messageBox.setDetailedText("Run:\npip install PyOpenGL PyOpenGL_accelerate")
- messageBox.exec_()
- sys.exit(1)
-
-
-class Bubble:
- def __init__(self, position, radius, velocity):
- self.position = position
- self.vel = velocity
- self.radius = radius
- self.innerColor = self.randomColor()
- self.outerColor = self.randomColor()
- self.updateBrush()
-
- def updateBrush(self):
- gradient = QRadialGradient(QPointF(self.radius, self.radius), self.radius,
- QPointF(self.radius*0.5, self.radius*0.5))
-
- gradient.setColorAt(0, QColor(255, 255, 255, 255))
- gradient.setColorAt(0.25, self.innerColor)
- gradient.setColorAt(1, self.outerColor)
- self.brush = QBrush(gradient)
-
- def drawBubble(self, painter):
- painter.save()
- painter.translate(self.position.x() - self.radius,
- self.position.y() - self.radius)
- painter.setBrush(self.brush)
- painter.drawEllipse(0, 0, int(2*self.radius), int(2*self.radius))
- painter.restore()
-
- def randomColor(self):
- red = random.randrange(205, 256)
- green = random.randrange(205, 256)
- blue = random.randrange(205, 256)
- alpha = random.randrange(91, 192)
-
- return QColor(red, green, blue, alpha)
-
- def move(self, bbox):
- self.position += self.vel
- leftOverflow = self.position.x() - self.radius - bbox.left()
- rightOverflow = self.position.x() + self.radius - bbox.right()
- topOverflow = self.position.y() - self.radius - bbox.top()
- bottomOverflow = self.position.y() + self.radius - bbox.bottom()
-
- if leftOverflow < 0.0:
- self.position.setX(self.position.x() - 2 * leftOverflow)
- self.vel.setX(-self.vel.x())
- elif rightOverflow > 0.0:
- self.position.setX(self.position.x() - 2 * rightOverflow)
- self.vel.setX(-self.vel.x())
-
- if topOverflow < 0.0:
- self.position.setY(self.position.y() - 2 * topOverflow)
- self.vel.setY(-self.vel.y())
- elif bottomOverflow > 0.0:
- self.position.setY(self.position.y() - 2 * bottomOverflow)
- self.vel.setY(-self.vel.y())
-
- def rect(self):
- return QRectF(self.position.x() - self.radius,
- self.position.y() - self.radius,
- 2 * self.radius, 2 * self.radius)
-
-
-class GLWidget(QGLWidget):
- def __init__(self, parent = None):
- QGLWidget.__init__(self, QGLFormat(QGL.SampleBuffers), parent)
-
- midnight = QTime(0, 0, 0)
- random.seed(midnight.secsTo(QTime.currentTime()))
-
- self.object = 0
- self.xRot = 0
- self.yRot = 0
- self.zRot = 0
- self.image = QImage()
- self.bubbles = []
- self.lastPos = QPoint()
-
- self.trolltechGreen = QColor.fromCmykF(0.40, 0.0, 1.0, 0.0)
- self.trolltechPurple = QColor.fromCmykF(0.39, 0.39, 0.0, 0.0)
-
- self.animationTimer = QTimer()
- self.animationTimer.setSingleShot(False)
- self.connect(self.animationTimer, SIGNAL("timeout()"), self.animate)
- self.animationTimer.start(25)
-
- self.setAttribute(Qt.WA_NoSystemBackground)
- self.setMinimumSize(200, 200)
- self.setWindowTitle(self.tr("Overpainting a Scene"))
-
- def freeResources(self):
- self.makeCurrent()
- glDeleteLists(self.object, 1)
-
- def setXRotation(self, angle):
- angle = self.normalizeAngle(angle)
- if angle != self.xRot:
- self.xRot = angle
- self.emit(SIGNAL("xRotationChanged(int)"), angle)
-
- def setYRotation(self, angle):
- angle = self.normalizeAngle(angle)
- if angle != self.yRot:
- self.yRot = angle
- self.emit(SIGNAL("yRotationChanged(int)"), angle)
-
- def setZRotation(self, angle):
- angle = self.normalizeAngle(angle)
- if angle != self.zRot:
- self.zRot = angle
- self.emit(SIGNAL("zRotationChanged(int)"), angle)
-
- def initializeGL(self):
- self.object = self.makeObject()
-
- def mousePressEvent(self, event):
- self.lastPos = QPoint(event.pos())
-
- def mouseMoveEvent(self, event):
- dx = event.x() - self.lastPos.x()
- dy = event.y() - self.lastPos.y()
-
- if event.buttons() & Qt.LeftButton:
- self.setXRotation(self.xRot + 8 * dy)
- self.setYRotation(self.yRot + 8 * dx)
- elif event.buttons() & Qt.RightButton:
- self.setXRotation(self.xRot + 8 * dy)
- self.setZRotation(self.zRot + 8 * dx)
-
- self.lastPos = QPoint(event.pos())
-
- def paintEvent(self, event):
- painter = QPainter()
- painter.begin(self)
- painter.setRenderHint(QPainter.Antialiasing)
-
- glPushAttrib(GL_ALL_ATTRIB_BITS)
- glMatrixMode(GL_PROJECTION)
- glPushMatrix()
- glMatrixMode(GL_MODELVIEW)
- glPushMatrix()
-
- self.qglClearColor(self.trolltechPurple.darker())
- glShadeModel(GL_SMOOTH)
- glEnable(GL_DEPTH_TEST)
- glEnable(GL_CULL_FACE)
- glEnable(GL_LIGHTING)
- glEnable(GL_LIGHT0)
- lightPosition = ( 0.5, 5.0, 7.0, 1.0 )
- glLightfv(GL_LIGHT0, GL_POSITION, lightPosition)
-
- self.resizeGL(self.width(), self.height())
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
- glLoadIdentity()
- glTranslated(0.0, 0.0, -10.0)
- glRotated(self.xRot / 16.0, 1.0, 0.0, 0.0)
- glRotated(self.yRot / 16.0, 0.0, 1.0, 0.0)
- glRotated(self.zRot / 16.0, 0.0, 0.0, 1.0)
- glCallList(self.object)
-
- glPopAttrib()
- glMatrixMode(GL_MODELVIEW)
- glPopMatrix()
- glMatrixMode(GL_PROJECTION)
- glPopMatrix()
-
- glDisable(GL_CULL_FACE) ### not required if begin() also does it
-
- for bubble in self.bubbles:
- if bubble.rect().intersects(QRectF(event.rect())):
- bubble.drawBubble(painter)
-
- painter.drawImage((self.width() - self.image.width())/2, 0, self.image)
- painter.end()
-
- def resizeGL(self, width, height):
- side = min(width, height)
- glViewport(int((width - side) / 2), int((height - side) / 2), side, side)
-
- glMatrixMode(GL_PROJECTION)
- glLoadIdentity()
- glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0)
- glMatrixMode(GL_MODELVIEW)
-
- self.formatInstructions(width, height)
-
- def showEvent(self, event):
- self.createBubbles(20 - len(self.bubbles))
-
- def sizeHint(self):
- return QSize(400, 400)
-
- def makeObject(self):
- list = glGenLists(1)
- glNewList(list, GL_COMPILE)
-
- glEnable(GL_NORMALIZE)
- glBegin(GL_QUADS)
-
- logoDiffuseColor = (self.trolltechGreen.red()/255.0,
- self.trolltechGreen.green()/255.0,
- self.trolltechGreen.blue()/255.0, 1.0)
- glMaterialfv(GL_FRONT, GL_DIFFUSE, logoDiffuseColor)
-
- x1 = +0.06
- y1 = -0.14
- x2 = +0.14
- y2 = -0.06
- x3 = +0.08
- y3 = +0.00
- x4 = +0.30
- y4 = +0.22
-
- self.quad(x1, y1, x2, y2, y2, x2, y1, x1)
- self.quad(x3, y3, x4, y4, y4, x4, y3, x3)
-
- self.extrude(x1, y1, x2, y2)
- self.extrude(x2, y2, y2, x2)
- self.extrude(y2, x2, y1, x1)
- self.extrude(y1, x1, x1, y1)
- self.extrude(x3, y3, x4, y4)
- self.extrude(x4, y4, y4, x4)
- self.extrude(y4, x4, y3, x3)
-
- NumSectors = 200
-
- for i in range(NumSectors):
- angle1 = (i * 2 * math.pi) / NumSectors
- x5 = 0.30 * math.sin(angle1)
- y5 = 0.30 * math.cos(angle1)
- x6 = 0.20 * math.sin(angle1)
- y6 = 0.20 * math.cos(angle1)
-
- angle2 = ((i + 1) * 2 * math.pi) / NumSectors
- x7 = 0.20 * math.sin(angle2)
- y7 = 0.20 * math.cos(angle2)
- x8 = 0.30 * math.sin(angle2)
- y8 = 0.30 * math.cos(angle2)
-
- self.quad(x5, y5, x6, y6, x7, y7, x8, y8)
-
- self.extrude(x6, y6, x7, y7)
- self.extrude(x8, y8, x5, y5)
-
- glEnd()
-
- glEndList()
- return list
-
- def quad(self, x1, y1, x2, y2, x3, y3, x4, y4):
- glNormal3d(0.0, 0.0, -1.0)
- glVertex3d(x1, y1, -0.05)
- glVertex3d(x2, y2, -0.05)
- glVertex3d(x3, y3, -0.05)
- glVertex3d(x4, y4, -0.05)
-
- glNormal3d(0.0, 0.0, 1.0)
- glVertex3d(x4, y4, +0.05)
- glVertex3d(x3, y3, +0.05)
- glVertex3d(x2, y2, +0.05)
- glVertex3d(x1, y1, +0.05)
-
- def extrude(self, x1, y1, x2, y2):
- self.qglColor(self.trolltechGreen.darker(250 + int(100 * x1)))
-
- glNormal3d((x1 + x2)/2.0, (y1 + y2)/2.0, 0.0)
- glVertex3d(x1, y1, +0.05)
- glVertex3d(x2, y2, +0.05)
- glVertex3d(x2, y2, -0.05)
- glVertex3d(x1, y1, -0.05)
-
- def normalizeAngle(self, angle):
- while angle < 0:
- angle += 360 * 16
- while angle > 360 * 16:
- angle -= 360 * 16
- return angle
-
- def createBubbles(self, number):
- for i in range(number):
- position = QPointF(self.width()*(0.1 + 0.8*random.random()),
- self.height()*(0.1 + 0.8*random.random()))
- radius = min(self.width(), self.height())*(0.0125 + 0.0875*random.random())
- velocity = QPointF(self.width()*0.0125*(-0.5 + random.random()),
- self.height()*0.0125*(-0.5 + random.random()))
-
- self.bubbles.append(Bubble(position, radius, velocity))
-
- def animate(self):
- for bubble in self.bubbles:
- self.update(bubble.rect().toRect())
- bubble.move(self.rect())
- self.update(bubble.rect().toRect())
-
- def formatInstructions(self, width, height):
- text = self.tr("Click and drag with the left mouse button "
- "to rotate the Qt logo.")
- metrics = QFontMetrics(self.font())
- border = max(4, metrics.leading())
-
- rect = metrics.boundingRect(0, 0, width - 2*border, int(height*0.125),
- Qt.AlignCenter | Qt.TextWordWrap, text)
- self.image = QImage(width, rect.height() + 2*border,
- QImage.Format_ARGB32_Premultiplied)
- self.image.fill(qRgba(0, 0, 0, 127))
-
- painter = QPainter()
- painter.begin(self.image)
- painter.setRenderHint(QPainter.TextAntialiasing)
- painter.setPen(Qt.white)
- painter.drawText((width - rect.width())/2, border,
- rect.width(), rect.height(),
- Qt.AlignCenter | Qt.TextWordWrap, text)
- painter.end()
-
-
-if __name__ == '__main__':
- app = QApplication(sys.argv)
- window = GLWidget()
- window.show()
- res = app.exec_()
- window.freeResources()
- sys.exit(res)
diff --git a/examples/opengl/samplebuffers.py b/examples/opengl/samplebuffers.py
deleted file mode 100644
index ad5b79466..000000000
--- a/examples/opengl/samplebuffers.py
+++ /dev/null
@@ -1,192 +0,0 @@
-
-############################################################################
-##
-## 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 Qt for Python 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 opengl/legacy/samplebuffers example from Qt v5.x"""
-
-import sys
-import math
-from PySide2 import QtCore, QtGui, QtWidgets, QtOpenGL
-
-try:
- from OpenGL import GL
-except ImportError:
- app = QtWidgets.QApplication(sys.argv)
- messageBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, "OpenGL samplebuffers",
- "PyOpenGL must be installed to run this example.",
- QtWidgets.QMessageBox.Close)
- messageBox.setDetailedText("Run:\npip install PyOpenGL PyOpenGL_accelerate")
- messageBox.exec_()
- sys.exit(1)
-
-
-class GLWidget(QtOpenGL.QGLWidget):
- GL_MULTISAMPLE = 0x809D
- rot = 0.0
-
- def __init__(self, parent=None):
- QtOpenGL.QGLWidget.__init__(self, QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers), parent)
-
- self.list_ = []
-
- self.startTimer(40)
- self.setWindowTitle(self.tr("Sample Buffers"))
-
- def initializeGL(self):
- GL.glMatrixMode(GL.GL_PROJECTION)
- GL.glLoadIdentity()
- GL.glOrtho( -.5, .5, .5, -.5, -1000, 1000)
- GL.glMatrixMode(GL.GL_MODELVIEW)
- GL.glLoadIdentity()
- GL.glClearColor(1.0, 1.0, 1.0, 1.0)
-
- self.makeObject()
-
- def resizeGL(self, w, h):
- GL.glViewport(0, 0, w, h)
-
- def paintGL(self):
- GL.glClear(GL.GL_COLOR_BUFFER_BIT)
-
- GL.glMatrixMode(GL.GL_MODELVIEW)
- GL.glPushMatrix()
- GL.glEnable(GLWidget.GL_MULTISAMPLE)
- GL.glTranslatef( -0.25, -0.10, 0.0)
- GL.glScalef(0.75, 1.15, 0.0)
- GL.glRotatef(GLWidget.rot, 0.0, 0.0, 1.0)
- GL.glCallList(self.list_)
- GL.glPopMatrix()
-
- GL.glPushMatrix()
- GL.glDisable(GLWidget.GL_MULTISAMPLE)
- GL.glTranslatef(0.25, -0.10, 0.0)
- GL.glScalef(0.75, 1.15, 0.0)
- GL.glRotatef(GLWidget.rot, 0.0, 0.0, 1.0)
- GL.glCallList(self.list_)
- GL.glPopMatrix()
-
- GLWidget.rot += 0.2
-
- self.qglColor(QtCore.Qt.black)
- self.renderText(-0.35, 0.4, 0.0, "Multisampling enabled")
- self.renderText(0.15, 0.4, 0.0, "Multisampling disabled")
-
- def timerEvent(self, event):
- self.update()
-
- def makeObject(self):
- trolltechGreen = QtGui.QColor.fromCmykF(0.40, 0.0, 1.0, 0.0)
- Pi = 3.14159265358979323846
- NumSectors = 15
- x1 = +0.06
- y1 = -0.14
- x2 = +0.14
- y2 = -0.06
- x3 = +0.08
- y3 = +0.00
- x4 = +0.30
- y4 = +0.22
-
- self.list_ = GL.glGenLists(1)
- GL.glNewList(self.list_, GL.GL_COMPILE)
-
- for i in range(NumSectors):
- angle1 = float((i * 2 * Pi) / NumSectors)
- x5 = 0.30 * math.sin(angle1)
- y5 = 0.30 * math.cos(angle1)
- x6 = 0.20 * math.sin(angle1)
- y6 = 0.20 * math.cos(angle1)
-
- angle2 = float(((i + 1) * 2 * Pi) / NumSectors)
- x7 = 0.20 * math.sin(angle2)
- y7 = 0.20 * math.cos(angle2)
- x8 = 0.30 * math.sin(angle2)
- y8 = 0.30 * math.cos(angle2)
-
- self.qglColor(trolltechGreen)
- self.quad(GL.GL_QUADS, x5, y5, x6, y6, x7, y7, x8, y8)
- self.qglColor(QtCore.Qt.black)
- self.quad(GL.GL_LINE_LOOP, x5, y5, x6, y6, x7, y7, x8, y8)
-
- self.qglColor(trolltechGreen)
- self.quad(GL.GL_QUADS, x1, y1, x2, y2, y2, x2, y1, x1)
- self.quad(GL.GL_QUADS, x3, y3, x4, y4, y4, x4, y3, x3)
-
- self.qglColor(QtCore.Qt.black)
- self.quad(GL.GL_LINE_LOOP, x1, y1, x2, y2, y2, x2, y1, x1)
- self.quad(GL.GL_LINE_LOOP, x3, y3, x4, y4, y4, x4, y3, x3)
-
- GL.glEndList()
-
- def quad(self, primitive, x1, y1, x2, y2, x3, y3, x4, y4):
- GL.glBegin(primitive)
-
- GL.glVertex2d(x1, y1)
- GL.glVertex2d(x2, y2)
- GL.glVertex2d(x3, y3)
- GL.glVertex2d(x4, y4)
-
- GL.glEnd()
-
- def freeResources(self):
- self.makeCurrent()
- GL.glDeleteLists(self.list_, 1)
-
-
-if __name__ == '__main__':
- app = QtWidgets.QApplication(sys.argv)
-
- if not QtOpenGL.QGLFormat.hasOpenGL():
- QMessageBox.information(0, "OpenGL pbuffers",
- "This system does not support OpenGL.",
- QMessageBox.Ok)
- sys.exit(1)
-
- f = QtOpenGL.QGLFormat.defaultFormat()
- f.setSampleBuffers(True)
- QtOpenGL.QGLFormat.setDefaultFormat(f)
-
- widget = GLWidget()
- widget.resize(640, 480)
- widget.show()
- res = app.exec_()
- widget.freeResources()
- sys.exit(res)
diff --git a/examples/samplebinding/CMakeLists.txt b/examples/samplebinding/CMakeLists.txt
index cb61358bf..f7651e04f 100644
--- a/examples/samplebinding/CMakeLists.txt
+++ b/examples/samplebinding/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 3.1)
-cmake_policy(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
+cmake_policy(VERSION 3.16)
# Enable policy to not use RPATH settings for install_name on macOS.
if(POLICY CMP0068)
diff --git a/examples/script/README.md b/examples/script/README.md
deleted file mode 100644
index 6133f4302..000000000
--- a/examples/script/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# About QtScript
-
-The QtScript module is deprecated since Qt 5.5,
-and hence is not being distributed through our wheels.
-
-However, it is possible to access the module
-when using a local build of PySide2 which was built
-against a Qt installation containing the Qt Script module
-(ALL_OPTIONAL_MODULES in `sources/pyside2/CMakeLists.txt`).
diff --git a/examples/script/helloscript.py b/examples/script/helloscript.py
deleted file mode 100644
index 2f0379a7e..000000000
--- a/examples/script/helloscript.py
+++ /dev/null
@@ -1,60 +0,0 @@
-
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: http://www.qt.io/licensing/
-##
-## This file is part of the Qt for Python 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 QtWidgets, QtScript
-
-
-app = QtWidgets.QApplication(sys.argv)
-
-engine = QtScript.QScriptEngine()
-
-button = QtWidgets.QPushButton()
-scriptButton = engine.newQObject(button)
-engine.globalObject().setProperty("button", scriptButton)
-
-engine.evaluate("button.text = 'Hello World from PySide2!'")
-engine.evaluate("button.styleSheet = 'font-style: italic'")
-engine.evaluate("button.show()")
-
-sys.exit(app.exec_())
diff --git a/examples/script/script.pyproject b/examples/script/script.pyproject
deleted file mode 100644
index 5beba8c3a..000000000
--- a/examples/script/script.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["README.md", "helloscript.py"]
-}
diff --git a/examples/scriptableapplication/CMakeLists.txt b/examples/scriptableapplication/CMakeLists.txt
index 999206425..8537ed8fb 100644
--- a/examples/scriptableapplication/CMakeLists.txt
+++ b/examples/scriptableapplication/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 3.1)
-cmake_policy(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
+cmake_policy(VERSION 3.16)
# Enable policy to run automoc on generated files.
if(POLICY CMP0071)
diff --git a/examples/scriptableapplication/mainwindow.cpp b/examples/scriptableapplication/mainwindow.cpp
index 53aea3c71..ed12f94b1 100644
--- a/examples/scriptableapplication/mainwindow.cpp
+++ b/examples/scriptableapplication/mainwindow.cpp
@@ -51,7 +51,7 @@
#include "mainwindow.h"
#include "pythonutils.h"
-#include <QtWidgets/QAction>
+#include <QtGui.QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
diff --git a/examples/webenginewidgets/tabbedbrowser/main.py b/examples/webenginewidgets/tabbedbrowser/main.py
index 438dd5c9d..086946bac 100644
--- a/examples/webenginewidgets/tabbedbrowser/main.py
+++ b/examples/webenginewidgets/tabbedbrowser/main.py
@@ -49,8 +49,8 @@ from findtoolbar import FindToolBar
from webengineview import WebEngineView
from PySide2 import QtCore
from PySide2.QtCore import Qt, QUrl
-from PySide2.QtGui import QKeySequence, QIcon
-from PySide2.QtWidgets import (QAction, QApplication, QDockWidget, QLabel,
+from PySide2.QtGui import QAction, QKeySequence, QIcon
+from PySide2.QtWidgets import (QApplication, QDockWidget, QLabel,
QLineEdit, QMainWindow, QToolBar)
from PySide2.QtWebEngineWidgets import QWebEngineDownloadItem, QWebEnginePage
diff --git a/examples/widgetbinding/CMakeLists.txt b/examples/widgetbinding/CMakeLists.txt
index a557f90ec..2966e63b2 100644
--- a/examples/widgetbinding/CMakeLists.txt
+++ b/examples/widgetbinding/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 3.1)
-cmake_policy(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
+cmake_policy(VERSION 3.16)
# Enable policy to not use RPATH settings for install_name on macOS.
if(POLICY CMP0068)
diff --git a/examples/widgets/animation/easing/easing.py b/examples/widgets/animation/easing/easing.py
index 18b5c09de..d5c733863 100644
--- a/examples/widgets/animation/easing/easing.py
+++ b/examples/widgets/animation/easing/easing.py
@@ -121,7 +121,7 @@ class Window(QtWidgets.QWidget):
m_ui.overshootSpinBox.setValue(dummy.overshoot())
m_ui.easingCurvePicker.currentRowChanged.connect(self.curveChanged)
- m_ui.buttonGroup.buttonClicked[int].connect(self.pathChanged)
+ m_ui.buttonGroup.idClicked.connect(self.pathChanged)
m_ui.periodSpinBox.valueChanged.connect(self.periodChanged)
m_ui.amplitudeSpinBox.valueChanged.connect(self.amplitudeChanged)
m_ui.overshootSpinBox.valueChanged.connect(self.overshootChanged)
diff --git a/examples/widgets/codeeditor/codeeditor.py b/examples/widgets/codeeditor/codeeditor.py
index 331069f4a..d83d010d4 100644
--- a/examples/widgets/codeeditor/codeeditor.py
+++ b/examples/widgets/codeeditor/codeeditor.py
@@ -74,7 +74,7 @@ class CodeEditor(QPlainTextEdit):
max_num *= 0.1
digits += 1
- space = 3 + self.fontMetrics().width('9') * digits
+ space = 3 + self.fontMetrics().horizontalAdvance('9') * digits
return space
def resizeEvent(self, e):
diff --git a/examples/widgets/dialogs/standarddialogs.py b/examples/widgets/dialogs/standarddialogs.py
index f61157e75..ea1afa4ce 100644
--- a/examples/widgets/dialogs/standarddialogs.py
+++ b/examples/widgets/dialogs/standarddialogs.py
@@ -119,7 +119,7 @@ class Dialog(QtWidgets.QDialog):
self.errorLabel = QtWidgets.QLabel()
self.errorLabel.setFrameStyle(frameStyle)
- self.errorButton = QtWidgets.QPushButton("QErrorMessage.show&M&essage()")
+ self.errorButton = QtWidgets.QPushButton("QErrorMessage.showM&essage()")
self.integerButton.clicked.connect(self.setInteger)
self.doubleButton.clicked.connect(self.setDouble)
diff --git a/examples/widgets/gallery/widgetgallery.py b/examples/widgets/gallery/widgetgallery.py
index a06ac2e20..9d3faeeff 100644
--- a/examples/widgets/gallery/widgetgallery.py
+++ b/examples/widgets/gallery/widgetgallery.py
@@ -42,8 +42,8 @@ import sys
from PySide2.QtWidgets import *
from PySide2.QtGui import (QCursor, QDesktopServices, QGuiApplication, QIcon,
- QKeySequence, QStandardItem, QStandardItemModel,
- QScreen, QWindow)
+ QKeySequence, QShortcut, QStandardItem,
+ QStandardItemModel, QScreen, QWindow)
from PySide2.QtCore import (QDateTime, QDir, QLibraryInfo, QMetaObject,
QSysInfo, QTextStream, QTimer, Qt, qVersion)
diff --git a/examples/widgets/graphicsview/diagramscene/diagramscene.py b/examples/widgets/graphicsview/diagramscene/diagramscene.py
index 3890782c4..079ae4021 100644
--- a/examples/widgets/graphicsview/diagramscene/diagramscene.py
+++ b/examples/widgets/graphicsview/diagramscene/diagramscene.py
@@ -550,7 +550,7 @@ class MainWindow(QtWidgets.QMainWindow):
def createToolBox(self):
self.buttonGroup = QtWidgets.QButtonGroup()
self.buttonGroup.setExclusive(False)
- self.buttonGroup.buttonClicked[int].connect(self.buttonGroupClicked)
+ self.buttonGroup.idClicked.connect(self.buttonGroupClicked)
layout = QtWidgets.QGridLayout()
layout.addWidget(self.createCellWidget("Conditional", DiagramItem.Conditional),
@@ -607,38 +607,38 @@ class MainWindow(QtWidgets.QMainWindow):
self.toolBox.addItem(backgroundWidget, "Backgrounds")
def createActions(self):
- self.toFrontAction = QtWidgets.QAction(
+ self.toFrontAction = QtGui.QAction(
QtGui.QIcon(':/images/bringtofront.png'), "Bring to &Front",
self, shortcut="Ctrl+F", statusTip="Bring item to front",
triggered=self.bringToFront)
- self.sendBackAction = QtWidgets.QAction(
+ self.sendBackAction = QtGui.QAction(
QtGui.QIcon(':/images/sendtoback.png'), "Send to &Back", self,
shortcut="Ctrl+B", statusTip="Send item to back",
triggered=self.sendToBack)
- self.deleteAction = QtWidgets.QAction(QtGui.QIcon(':/images/delete.png'),
+ self.deleteAction = QtGui.QAction(QtGui.QIcon(':/images/delete.png'),
"&Delete", self, shortcut="Delete",
statusTip="Delete item from diagram",
triggered=self.deleteItem)
- self.exitAction = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+X",
+ self.exitAction = QtGui.QAction("E&xit", self, shortcut="Ctrl+X",
statusTip="Quit Scenediagram example", triggered=self.close)
- self.boldAction = QtWidgets.QAction(QtGui.QIcon(':/images/bold.png'),
+ self.boldAction = QtGui.QAction(QtGui.QIcon(':/images/bold.png'),
"Bold", self, checkable=True, shortcut="Ctrl+B",
triggered=self.handleFontChange)
- self.italicAction = QtWidgets.QAction(QtGui.QIcon(':/images/italic.png'),
+ self.italicAction = QtGui.QAction(QtGui.QIcon(':/images/italic.png'),
"Italic", self, checkable=True, shortcut="Ctrl+I",
triggered=self.handleFontChange)
- self.underlineAction = QtWidgets.QAction(
+ self.underlineAction = QtGui.QAction(
QtGui.QIcon(':/images/underline.png'), "Underline", self,
checkable=True, shortcut="Ctrl+U",
triggered=self.handleFontChange)
- self.aboutAction = QtWidgets.QAction("A&bout", self, shortcut="Ctrl+B",
+ self.aboutAction = QtGui.QAction("A&bout", self, shortcut="Ctrl+B",
triggered=self.about)
def createMenus(self):
@@ -726,12 +726,12 @@ class MainWindow(QtWidgets.QMainWindow):
self.pointerTypeGroup.addButton(pointerButton, DiagramScene.MoveItem)
self.pointerTypeGroup.addButton(linePointerButton,
DiagramScene.InsertLine)
- self.pointerTypeGroup.buttonClicked[int].connect(self.pointerGroupClicked)
+ self.pointerTypeGroup.idClicked.connect(self.pointerGroupClicked)
self.sceneScaleCombo = QtWidgets.QComboBox()
self.sceneScaleCombo.addItems(["50%", "75%", "100%", "125%", "150%"])
self.sceneScaleCombo.setCurrentIndex(2)
- self.sceneScaleCombo.currentIndexChanged[str].connect(self.sceneScaleChanged)
+ self.sceneScaleCombo.currentTextChanged.connect(self.sceneScaleChanged)
self.pointerToolbar = self.addToolBar("Pointer type")
self.pointerToolbar.addWidget(pointerButton)
@@ -780,7 +780,7 @@ class MainWindow(QtWidgets.QMainWindow):
colorMenu = QtWidgets.QMenu(self)
for color, name in zip(colors, names):
- action = QtWidgets.QAction(self.createColorIcon(color), name, self,
+ action = QtGui.QAction(self.createColorIcon(color), name, self,
triggered=slot)
action.setData(QtGui.QColor(color))
colorMenu.addAction(action)
diff --git a/examples/widgets/itemviews/addressbook/addressbook.py b/examples/widgets/itemviews/addressbook/addressbook.py
index 262027a64..35d095287 100644
--- a/examples/widgets/itemviews/addressbook/addressbook.py
+++ b/examples/widgets/itemviews/addressbook/addressbook.py
@@ -40,7 +40,8 @@
##
#############################################################################
-from PySide2.QtWidgets import (QMainWindow, QAction, QFileDialog, QApplication)
+from PySide2.QtGui import QAction
+from PySide2.QtWidgets import (QMainWindow, QFileDialog, QApplication)
from addresswidget import AddressWidget
diff --git a/examples/widgets/mainwindows/application/application.py b/examples/widgets/mainwindows/application/application.py
index 8c4626f9b..d68e77b41 100644
--- a/examples/widgets/mainwindows/application/application.py
+++ b/examples/widgets/mainwindows/application/application.py
@@ -106,46 +106,46 @@ class MainWindow(QtWidgets.QMainWindow):
self.setWindowModified(self.textEdit.document().isModified())
def createActions(self):
- self.newAct = QtWidgets.QAction(QtGui.QIcon(':/images/new.png'), "&New",
+ self.newAct = QtGui.QAction(QtGui.QIcon(':/images/new.png'), "&New",
self, shortcut=QtGui.QKeySequence.New,
statusTip="Create a new file", triggered=self.newFile)
- self.openAct = QtWidgets.QAction(QtGui.QIcon(':/images/open.png'),
+ self.openAct = QtGui.QAction(QtGui.QIcon(':/images/open.png'),
"&Open...", self, shortcut=QtGui.QKeySequence.Open,
statusTip="Open an existing file", triggered=self.open)
- self.saveAct = QtWidgets.QAction(QtGui.QIcon(':/images/save.png'),
+ self.saveAct = QtGui.QAction(QtGui.QIcon(':/images/save.png'),
"&Save", self, shortcut=QtGui.QKeySequence.Save,
statusTip="Save the document to disk", triggered=self.save)
- self.saveAsAct = QtWidgets.QAction("Save &As...", self,
+ self.saveAsAct = QtGui.QAction("Save &As...", self,
shortcut=QtGui.QKeySequence.SaveAs,
statusTip="Save the document under a new name",
triggered=self.saveAs)
- self.exitAct = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+Q",
+ self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q",
statusTip="Exit the application", triggered=self.close)
- self.cutAct = QtWidgets.QAction(QtGui.QIcon(':/images/cut.png'), "Cu&t",
+ self.cutAct = QtGui.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 = QtWidgets.QAction(QtGui.QIcon(':/images/copy.png'),
+ self.copyAct = QtGui.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 = QtWidgets.QAction(QtGui.QIcon(':/images/paste.png'),
+ self.pasteAct = QtGui.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 = QtWidgets.QAction("&About", self,
+ self.aboutAct = QtGui.QAction("&About", self,
statusTip="Show the application's About box",
triggered=self.about)
- self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
+ self.aboutQtAct = QtGui.QAction("About &Qt", self,
statusTip="Show the Qt library's About box",
triggered=qApp.aboutQt)
diff --git a/examples/widgets/mainwindows/dockwidgets/dockwidgets.py b/examples/widgets/mainwindows/dockwidgets/dockwidgets.py
index 53f6f7818..87a818c05 100644
--- a/examples/widgets/mainwindows/dockwidgets/dockwidgets.py
+++ b/examples/widgets/mainwindows/dockwidgets/dockwidgets.py
@@ -43,10 +43,10 @@
"""PySide2 port of the widgets/mainwindows/dockwidgets example from Qt v5.x, originating from PyQt"""
from PySide2.QtCore import QDate, QFile, Qt, QTextStream
-from PySide2.QtGui import (QFont, QIcon, QKeySequence, QTextCharFormat,
- QTextCursor, QTextTableFormat)
+from PySide2.QtGui import (QAction, QFont, QIcon, QKeySequence,
+ QTextCharFormat, QTextCursor, QTextTableFormat)
from PySide2.QtPrintSupport import QPrintDialog, QPrinter
-from PySide2.QtWidgets import (QAction, QApplication, QDialog, QDockWidget,
+from PySide2.QtWidgets import (QApplication, QDialog, QDockWidget,
QFileDialog, QListWidget, QMainWindow, QMessageBox, QTextEdit)
import dockwidgets_rc
diff --git a/examples/widgets/mainwindows/mdi/mdi.py b/examples/widgets/mainwindows/mdi/mdi.py
index 9daca826d..18bbfa5fb 100644
--- a/examples/widgets/mainwindows/mdi/mdi.py
+++ b/examples/widgets/mainwindows/mdi/mdi.py
@@ -44,8 +44,8 @@
from PySide2.QtCore import (QFile, QFileInfo, QPoint, QSettings, QSignalMapper,
QSaveFile, QSize, QTextStream, Qt)
-from PySide2.QtGui import QIcon, QKeySequence
-from PySide2.QtWidgets import (QAction, QApplication, QFileDialog, QMainWindow,
+from PySide2.QtGui import QAction, QIcon, QKeySequence
+from PySide2.QtWidgets import (QApplication, QFileDialog, QMainWindow,
QMdiArea, QMessageBox, QTextEdit, QWidget)
import mdi_rc
@@ -171,7 +171,7 @@ class MainWindow(QMainWindow):
self.mdiArea.subWindowActivated.connect(self.updateMenus)
self.windowMapper = QSignalMapper(self)
- self.windowMapper.mapped[QWidget].connect(self.setActiveSubWindow)
+ self.windowMapper.mappedObject.connect(self.setActiveSubWindow)
self.createActions()
self.createMenus()
diff --git a/examples/widgets/state-machine/rogue.py b/examples/widgets/state-machine/rogue.py
index 755b847ac..ce5b80596 100644
--- a/examples/widgets/state-machine/rogue.py
+++ b/examples/widgets/state-machine/rogue.py
@@ -146,12 +146,13 @@ class MainWindow(QMainWindow):
def sizeHint(self):
metrics = QFontMetrics(self.font())
- return QSize(metrics.width('X') * self.width, metrics.height() * (self.height + 1))
+ return QSize(metrics.horizontalAdvance('X') * self.width,
+ metrics.height() * (self.height + 1))
def paintEvent(self, event):
metrics = QFontMetrics(self.font())
painter = QPainter(self)
fontHeight = metrics.height()
- fontWidth = metrics.width('X')
+ fontWidth = metrics.horizontalAdvance('X')
painter.fillRect(self.rect(), Qt.black)
painter.setPen(Qt.white)
diff --git a/examples/widgets/systray/window.py b/examples/widgets/systray/window.py
index ca65f04e1..634646327 100644
--- a/examples/widgets/systray/window.py
+++ b/examples/widgets/systray/window.py
@@ -39,8 +39,8 @@
#############################################################################
from PySide2.QtCore import Slot
-from PySide2.QtGui import QIcon
-from PySide2.QtWidgets import (QAction, QCheckBox, QComboBox, QDialog,
+from PySide2.QtGui import QAction, QIcon
+from PySide2.QtWidgets import (QCheckBox, QComboBox, QDialog,
QGridLayout, QGroupBox, QHBoxLayout, QLabel,
QLineEdit, QMenu, QMessageBox, QPushButton,
QSpinBox, QStyle, QSystemTrayIcon, QTextEdit,
diff --git a/examples/widgets/widgets/hellogl_openglwidget_legacy.py b/examples/widgets/widgets/hellogl_openglwidget_legacy.py
deleted file mode 100644
index 8745b4e8d..000000000
--- a/examples/widgets/widgets/hellogl_openglwidget_legacy.py
+++ /dev/null
@@ -1,288 +0,0 @@
-
-############################################################################
-##
-## Copyright (C) 2017 The Qt Company Ltd.
-## Contact: http://www.qt.io/licensing/
-##
-## This file is part of the Qt for Python 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 opengl/legacy/hellogl example from Qt v5.x modified to use a QOpenGLWidget to demonstrate porting from QGLWidget to QOpenGLWidget"""
-
-import sys
-import math
-from PySide2 import QtCore, QtGui, QtWidgets
-
-try:
- from OpenGL import GL
-except ImportError:
- app = QtWidgets.QApplication(sys.argv)
- messageBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, "OpenGL hellogl",
- "PyOpenGL must be installed to run this example.",
- QtWidgets.QMessageBox.Close)
- messageBox.setDetailedText("Run:\npip install PyOpenGL PyOpenGL_accelerate")
- messageBox.exec_()
- sys.exit(1)
-
-
-class Window(QtWidgets.QWidget):
- def __init__(self, parent=None):
- QtWidgets.QWidget.__init__(self, parent)
-
- self.glWidget = GLWidget()
-
- self.xSlider = self.createSlider(QtCore.SIGNAL("xRotationChanged(int)"),
- self.glWidget.setXRotation)
- self.ySlider = self.createSlider(QtCore.SIGNAL("yRotationChanged(int)"),
- self.glWidget.setYRotation)
- self.zSlider = self.createSlider(QtCore.SIGNAL("zRotationChanged(int)"),
- self.glWidget.setZRotation)
-
- mainLayout = QtWidgets.QHBoxLayout()
- mainLayout.addWidget(self.glWidget)
- mainLayout.addWidget(self.xSlider)
- mainLayout.addWidget(self.ySlider)
- mainLayout.addWidget(self.zSlider)
- self.setLayout(mainLayout)
-
- self.xSlider.setValue(170 * 16)
- self.ySlider.setValue(160 * 16)
- self.zSlider.setValue(90 * 16)
-
- self.setWindowTitle(self.tr("QOpenGLWidget"))
-
- def createSlider(self, changedSignal, setterSlot):
- slider = QtWidgets.QSlider(QtCore.Qt.Vertical)
-
- slider.setRange(0, 360 * 16)
- slider.setSingleStep(16)
- slider.setPageStep(15 * 16)
- slider.setTickInterval(15 * 16)
- slider.setTickPosition(QtWidgets.QSlider.TicksRight)
-
- self.glWidget.connect(slider, QtCore.SIGNAL("valueChanged(int)"), setterSlot)
- self.connect(self.glWidget, changedSignal, slider, QtCore.SLOT("setValue(int)"))
-
- return slider
-
-
-class GLWidget(QtWidgets.QOpenGLWidget):
- xRotationChanged = QtCore.Signal(int)
- yRotationChanged = QtCore.Signal(int)
- zRotationChanged = QtCore.Signal(int)
-
- def __init__(self, parent=None):
- QtWidgets.QOpenGLWidget.__init__(self, parent)
-
- self.object = 0
- self.xRot = 0
- self.yRot = 0
- self.zRot = 0
-
- self.lastPos = QtCore.QPoint()
-
- self.trolltechGreen = QtGui.QColor.fromCmykF(0.40, 0.0, 1.0, 0.0)
- self.trolltechPurple = QtGui.QColor.fromCmykF(0.39, 0.39, 0.0, 0.0)
-
- def xRotation(self):
- return self.xRot
-
- def yRotation(self):
- return self.yRot
-
- def zRotation(self):
- return self.zRot
-
- def minimumSizeHint(self):
- return QtCore.QSize(50, 50)
-
- def sizeHint(self):
- return QtCore.QSize(400, 400)
-
- def setXRotation(self, angle):
- angle = self.normalizeAngle(angle)
- if angle != self.xRot:
- self.xRot = angle
- self.emit(QtCore.SIGNAL("xRotationChanged(int)"), angle)
- self.update()
-
- def setYRotation(self, angle):
- angle = self.normalizeAngle(angle)
- if angle != self.yRot:
- self.yRot = angle
- self.emit(QtCore.SIGNAL("yRotationChanged(int)"), angle)
- self.update()
-
- def setZRotation(self, angle):
- angle = self.normalizeAngle(angle)
- if angle != self.zRot:
- self.zRot = angle
- self.emit(QtCore.SIGNAL("zRotationChanged(int)"), angle)
- self.update()
-
- def initializeGL(self):
- darkTrolltechPurple = self.trolltechPurple.darker()
- GL.glClearColor(darkTrolltechPurple.redF(), darkTrolltechPurple.greenF(), darkTrolltechPurple.blueF(), darkTrolltechPurple.alphaF())
- self.object = self.makeObject()
- GL.glShadeModel(GL.GL_FLAT)
- GL.glEnable(GL.GL_DEPTH_TEST)
- GL.glEnable(GL.GL_CULL_FACE)
-
- def paintGL(self):
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
- GL.glLoadIdentity()
- GL.glTranslated(0.0, 0.0, -10.0)
- GL.glRotated(self.xRot / 16.0, 1.0, 0.0, 0.0)
- GL.glRotated(self.yRot / 16.0, 0.0, 1.0, 0.0)
- GL.glRotated(self.zRot / 16.0, 0.0, 0.0, 1.0)
- GL.glCallList(self.object)
-
- def resizeGL(self, width, height):
- side = min(width, height)
- GL.glViewport(int((width - side) / 2),int((height - side) / 2), side, side)
-
- GL.glMatrixMode(GL.GL_PROJECTION)
- GL.glLoadIdentity()
- GL.glOrtho(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0)
- GL.glMatrixMode(GL.GL_MODELVIEW)
-
- def mousePressEvent(self, event):
- self.lastPos = QtCore.QPoint(event.pos())
-
- def mouseMoveEvent(self, event):
- dx = event.x() - self.lastPos.x()
- dy = event.y() - self.lastPos.y()
-
- if event.buttons() & QtCore.Qt.LeftButton:
- self.setXRotation(self.xRot + 8 * dy)
- self.setYRotation(self.yRot + 8 * dx)
- elif event.buttons() & QtCore.Qt.RightButton:
- self.setXRotation(self.xRot + 8 * dy)
- self.setZRotation(self.zRot + 8 * dx)
-
- self.lastPos = QtCore.QPoint(event.pos())
-
- def makeObject(self):
- genList = GL.glGenLists(1)
- GL.glNewList(genList, GL.GL_COMPILE)
-
- GL.glBegin(GL.GL_QUADS)
-
- x1 = +0.06
- y1 = -0.14
- x2 = +0.14
- y2 = -0.06
- x3 = +0.08
- y3 = +0.00
- x4 = +0.30
- y4 = +0.22
-
- self.quad(x1, y1, x2, y2, y2, x2, y1, x1)
- self.quad(x3, y3, x4, y4, y4, x4, y3, x3)
-
- self.extrude(x1, y1, x2, y2)
- self.extrude(x2, y2, y2, x2)
- self.extrude(y2, x2, y1, x1)
- self.extrude(y1, x1, x1, y1)
- self.extrude(x3, y3, x4, y4)
- self.extrude(x4, y4, y4, x4)
- self.extrude(y4, x4, y3, x3)
-
- Pi = 3.14159265358979323846
- NumSectors = 200
-
- for i in range(NumSectors):
- angle1 = (i * 2 * Pi) / NumSectors
- x5 = 0.30 * math.sin(angle1)
- y5 = 0.30 * math.cos(angle1)
- x6 = 0.20 * math.sin(angle1)
- y6 = 0.20 * math.cos(angle1)
-
- angle2 = ((i + 1) * 2 * Pi) / NumSectors
- x7 = 0.20 * math.sin(angle2)
- y7 = 0.20 * math.cos(angle2)
- x8 = 0.30 * math.sin(angle2)
- y8 = 0.30 * math.cos(angle2)
-
- self.quad(x5, y5, x6, y6, x7, y7, x8, y8)
-
- self.extrude(x6, y6, x7, y7)
- self.extrude(x8, y8, x5, y5)
-
- GL.glEnd()
- GL.glEndList()
-
- return genList
-
- def quad(self, x1, y1, x2, y2, x3, y3, x4, y4):
- GL.glColor(self.trolltechGreen.redF(), self.trolltechGreen.greenF(), self.trolltechGreen.blueF(), self.trolltechGreen.alphaF())
-
- GL.glVertex3d(x1, y1, +0.05)
- GL.glVertex3d(x2, y2, +0.05)
- GL.glVertex3d(x3, y3, +0.05)
- GL.glVertex3d(x4, y4, +0.05)
-
- GL.glVertex3d(x4, y4, -0.05)
- GL.glVertex3d(x3, y3, -0.05)
- GL.glVertex3d(x2, y2, -0.05)
- GL.glVertex3d(x1, y1, -0.05)
-
- def extrude(self, x1, y1, x2, y2):
- darkTrolltechGreen = self.trolltechGreen.darker(250 + int(100 * x1))
- GL.glColor(darkTrolltechGreen.redF(), darkTrolltechGreen.greenF(), darkTrolltechGreen.blueF(), darkTrolltechGreen.alphaF())
-
- GL.glVertex3d(x1, y1, -0.05)
- GL.glVertex3d(x2, y2, -0.05)
- GL.glVertex3d(x2, y2, +0.05)
- GL.glVertex3d(x1, y1, +0.05)
-
- def normalizeAngle(self, angle):
- while angle < 0:
- angle += 360 * 16
- while angle > 360 * 16:
- angle -= 360 * 16
- return angle
-
- def freeResources(self):
- self.makeCurrent()
- GL.glDeleteLists(self.object, 1)
-
-if __name__ == '__main__':
- app = QtWidgets.QApplication(sys.argv)
- window = Window()
- window.show()
- res = app.exec_()
- window.glWidget.freeResources()
- sys.exit(res)
diff --git a/examples/xml/dombookmarks/dombookmarks.py b/examples/xml/dombookmarks/dombookmarks.py
index 20ec09e2d..f645bedce 100644
--- a/examples/xml/dombookmarks/dombookmarks.py
+++ b/examples/xml/dombookmarks/dombookmarks.py
@@ -100,18 +100,18 @@ class MainWindow(QtWidgets.QMainWindow):
"DOM classes to read and write XML documents.")
def createActions(self):
- self.openAct = QtWidgets.QAction("&Open...", self, shortcut="Ctrl+O",
+ self.openAct = QtGui.QAction("&Open...", self, shortcut="Ctrl+O",
triggered=self.open)
- self.saveAsAct = QtWidgets.QAction("&Save As...", self, shortcut="Ctrl+S",
+ self.saveAsAct = QtGui.QAction("&Save As...", self, shortcut="Ctrl+S",
triggered=self.saveAs)
- self.exitAct = QtWidgets.QAction("E&xit", self, shortcut="Ctrl+Q",
+ self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q",
triggered=self.close)
- self.aboutAct = QtWidgets.QAction("&About", self, triggered=self.about)
+ self.aboutAct = QtGui.QAction("&About", self, triggered=self.about)
- self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
+ self.aboutQtAct = QtGui.QAction("About &Qt", self,
triggered=qApp.aboutQt)
def createMenus(self):
diff --git a/examples/xmlpatterns/schema/files/contact.xsd b/examples/xmlpatterns/schema/files/contact.xsd
deleted file mode 100644
index 3e1b5704c..000000000
--- a/examples/xmlpatterns/schema/files/contact.xsd
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0"?>
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
- <xsd:element name="contact">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="givenName" type="xsd:string"/>
- <xsd:element name="familyName" type="xsd:string"/>
- <xsd:element name="birthdate" type="xsd:date" minOccurs="0"/>
- <xsd:element name="homeAddress" type="address"/>
- <xsd:element name="workAddress" type="address" minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:complexType name="address">
- <xsd:sequence>
- <xsd:element name="street" type="xsd:string"/>
- <xsd:element name="zipCode" type="xsd:string"/>
- <xsd:element name="city" type="xsd:string"/>
- <xsd:element name="country" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
-
-</xsd:schema>
diff --git a/examples/xmlpatterns/schema/files/invalid_contact.xml b/examples/xmlpatterns/schema/files/invalid_contact.xml
deleted file mode 100644
index 42f1edd67..000000000
--- a/examples/xmlpatterns/schema/files/invalid_contact.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<contact>
- <givenName>John</givenName>
- <familyName>Doe</familyName>
- <title>Prof.</title>
- <workAddress>
- <street>Sandakerveien 116</street>
- <zipCode>N-0550</zipCode>
- <city>Oslo</city>
- <country>Norway</country>
- </workAddress>
-</contact>
diff --git a/examples/xmlpatterns/schema/files/invalid_order.xml b/examples/xmlpatterns/schema/files/invalid_order.xml
deleted file mode 100644
index 8ffc5fda4..000000000
--- a/examples/xmlpatterns/schema/files/invalid_order.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<order>
- <customerId>234219</customerId>
- <article>
- <articleId>21692</articleId>
- <count>3</count>
- </article>
- <article>
- <articleId>24749</articleId>
- <count>9</count>
- </article>
- <deliveryDate>2009-01-23</deliveryDate>
- <payed>yes</payed>
-</order>
diff --git a/examples/xmlpatterns/schema/files/invalid_recipe.xml b/examples/xmlpatterns/schema/files/invalid_recipe.xml
deleted file mode 100644
index 4d75af6a1..000000000
--- a/examples/xmlpatterns/schema/files/invalid_recipe.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<recipe>
- <title>Cheese on Toast</title>
- <ingredient name="Bread" quantity="2" unit="slices"/>
- <ingredient name="Cheese" quantity="2" unit="slices"/>
- <time quantity="3" unit="days"/>
- <method>
- <step>1. Slice the bread and cheese.</step>
- <step>2. Grill one side of each slice of bread.</step>
- <step>3. Turn over the bread and place a slice of cheese on each piece.</step>
- <step>4. Grill until the cheese has started to melt.</step>
- <step>5. Serve and enjoy!</step>
- </method>
- <comment>Tell your friends about it!</comment>
-</recipe>
diff --git a/examples/xmlpatterns/schema/files/order.xsd b/examples/xmlpatterns/schema/files/order.xsd
deleted file mode 100644
index 405cafe43..000000000
--- a/examples/xmlpatterns/schema/files/order.xsd
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0"?>
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
- <xsd:element name="order">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="customerId" type="xsd:positiveInteger"/>
- <xsd:element name="article" type="articleType" maxOccurs="unbounded"/>
- <xsd:element name="deliveryDate" type="xsd:date"/>
- <xsd:element name="payed" type="xsd:boolean"/>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:complexType name="articleType">
- <xsd:sequence>
- <xsd:element name="articleId" type="xsd:positiveInteger"/>
- <xsd:element name="count" type="xsd:positiveInteger"/>
- <xsd:element name="comment" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
-</xsd:schema>
diff --git a/examples/xmlpatterns/schema/files/recipe.xsd b/examples/xmlpatterns/schema/files/recipe.xsd
deleted file mode 100644
index bbbafd9a3..000000000
--- a/examples/xmlpatterns/schema/files/recipe.xsd
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0"?>
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
- <xsd:element name="recipe">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="title" type="xsd:string"/>
- <xsd:element name="ingredient" type="ingredientType" maxOccurs="unbounded"/>
- <xsd:element name="time" type="timeType"/>
- <xsd:element name="method">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="step" type="xsd:string" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:complexType name="ingredientType">
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="quantity" type="xsd:positiveInteger"/>
- <xsd:attribute name="unit" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="timeType">
- <xsd:attribute name="quantity" type="xsd:positiveInteger"/>
- <xsd:attribute name="unit">
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="seconds"/>
- <xsd:enumeration value="minutes"/>
- <xsd:enumeration value="hours"/>
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:attribute>
- </xsd:complexType>
-
-</xsd:schema>
diff --git a/examples/xmlpatterns/schema/files/valid_contact.xml b/examples/xmlpatterns/schema/files/valid_contact.xml
deleted file mode 100644
index 53c04d4b5..000000000
--- a/examples/xmlpatterns/schema/files/valid_contact.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<contact>
- <givenName>John</givenName>
- <familyName>Doe</familyName>
- <birthdate>1977-12-25</birthdate>
- <homeAddress>
- <street>Sandakerveien 116</street>
- <zipCode>N-0550</zipCode>
- <city>Oslo</city>
- <country>Norway</country>
- </homeAddress>
-</contact>
diff --git a/examples/xmlpatterns/schema/files/valid_order.xml b/examples/xmlpatterns/schema/files/valid_order.xml
deleted file mode 100644
index f83c36cb1..000000000
--- a/examples/xmlpatterns/schema/files/valid_order.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<order>
- <customerId>194223</customerId>
- <article>
- <articleId>22242</articleId>
- <count>5</count>
- </article>
- <article>
- <articleId>32372</articleId>
- <count>12</count>
- <comment>without stripes</comment>
- </article>
- <article>
- <articleId>23649</articleId>
- <count>2</count>
- </article>
- <deliveryDate>2009-01-23</deliveryDate>
- <payed>true</payed>
-</order>
diff --git a/examples/xmlpatterns/schema/files/valid_recipe.xml b/examples/xmlpatterns/schema/files/valid_recipe.xml
deleted file mode 100644
index f6499ba21..000000000
--- a/examples/xmlpatterns/schema/files/valid_recipe.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<recipe>
- <title>Cheese on Toast</title>
- <ingredient name="Bread" quantity="2" unit="slices"/>
- <ingredient name="Cheese" quantity="2" unit="slices"/>
- <time quantity="3" unit="minutes"/>
- <method>
- <step>1. Slice the bread and cheese.</step>
- <step>2. Grill one side of each slice of bread.</step>
- <step>3. Turn over the bread and place a slice of cheese on each piece.</step>
- <step>4. Grill until the cheese has started to melt.</step>
- <step>5. Serve and enjoy!</step>
- </method>
-</recipe>
diff --git a/examples/xmlpatterns/schema/schema.py b/examples/xmlpatterns/schema/schema.py
deleted file mode 100644
index d3c22c184..000000000
--- a/examples/xmlpatterns/schema/schema.py
+++ /dev/null
@@ -1,286 +0,0 @@
-
-#############################################################################
-##
-## 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 Qt for Python 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
-
-
-try:
- # Python v2.
- unicode
-
- def encode_utf8(ba):
- return unicode(ba, encoding='utf8')
-
- def decode_utf8(qs):
- return QtCore.QByteArray(str(qs))
-
-except NameError:
- # Python v3.
-
- def encode_utf8(ba):
- return str(ba.data(), encoding='utf8')
-
- def decode_utf8(qs):
- return QtCore.QByteArray(bytes(qs, encoding='utf8'))
-
-
-class XmlSyntaxHighlighter(QtGui.QSyntaxHighlighter):
-
- def __init__(self, parent=None):
- super(XmlSyntaxHighlighter, self).__init__(parent)
-
- self.highlightingRules = []
-
- # Tag format.
- format = QtGui.QTextCharFormat()
- format.setForeground(QtCore.Qt.darkBlue)
- format.setFontWeight(QtGui.QFont.Bold)
- pattern = QtCore.QRegularExpression(r'(<[a-zA-Z:]+\b|<\?[a-zA-Z:]+\b|\?>|>|/>|</[a-zA-Z:]+>)')
- assert pattern.isValid()
- self.highlightingRules.append((pattern, format))
-
- # Attribute format.
- format = QtGui.QTextCharFormat()
- format.setForeground(QtCore.Qt.darkGreen)
- pattern = QtCore.QRegularExpression('[a-zA-Z:]+=')
- assert pattern.isValid()
- self.highlightingRules.append((pattern, format))
-
- # Attribute content format.
- format = QtGui.QTextCharFormat()
- format.setForeground(QtCore.Qt.red)
- pattern = QtCore.QRegularExpression("(\"[^\"]*\"|'[^']*')")
- assert pattern.isValid()
- self.highlightingRules.append((pattern, format))
-
- # Comment format.
- self.commentFormat = QtGui.QTextCharFormat()
- self.commentFormat.setForeground(QtCore.Qt.lightGray)
- self.commentFormat.setFontItalic(True)
-
- self.commentStartExpression = QtCore.QRegularExpression("<!--")
- assert self.commentStartExpression.isValid()
- self.commentEndExpression = QtCore.QRegularExpression("-->")
- assert self.commentEndExpression.isValid()
-
- def highlightBlock(self, text):
- for pattern, format in self.highlightingRules:
- match = pattern.match(text)
- while match.hasMatch():
- index = match.capturedStart()
- length = match.capturedLength(0)
- self.setFormat(index, length, format)
- match = pattern.match(text, index + length)
-
- self.setCurrentBlockState(0)
-
- startIndex = 0
- if self.previousBlockState() != 1:
- match = self.commentStartExpression.match(text)
- startIndex = match.capturedStart(0) if match.hasMatch() else -1
-
- while startIndex >= 0:
- match = self.commentEndExpression.match(text, startIndex)
- endIndex = match.capturedStart(0) if match.hasMatch() else -1
- if match.hasMatch():
- endIndex = match.capturedStart(0)
- length = match.capturedLength(0)
- commentLength = endIndex - startIndex + length
- else:
- self.setCurrentBlockState(1)
- commentLength = text.length() - startIndex
-
- self.setFormat(startIndex, commentLength, self.commentFormat)
- match = self.commentStartExpression.match(text, startIndex + commentLength)
- startIndex = match.capturedStart(0) if match.hasMatch() else -1
-
-
-class MessageHandler(QtXmlPatterns.QAbstractMessageHandler):
-
- def __init__(self):
- super(MessageHandler, self).__init__()
-
- self.m_description = ""
- self.m_sourceLocation = QtXmlPatterns.QSourceLocation()
-
- def statusMessage(self):
- return self.m_description
-
- def line(self):
- return self.m_sourceLocation.line()
-
- def column(self):
- return self.m_sourceLocation.column()
-
- def handleMessage(self, type, description, identifier, sourceLocation):
- self.m_description = description
- self.m_sourceLocation = sourceLocation
-
-
-class MainWindow(QtWidgets.QMainWindow, Ui_SchemaMainWindow):
-
- def __init__(self):
- QtWidgets.QMainWindow.__init__(self)
-
- self.setupUi(self)
-
- XmlSyntaxHighlighter(self.schemaView.document())
- XmlSyntaxHighlighter(self.instanceEdit.document())
-
- self.schemaSelection.addItem("Contact Schema")
- self.schemaSelection.addItem("Recipe Schema")
- self.schemaSelection.addItem("Order Schema")
-
- self.instanceSelection.addItem("Valid Contact Instance")
- self.instanceSelection.addItem("Invalid Contact Instance")
-
- self.schemaSelection.currentIndexChanged[int].connect(self.schemaSelected)
- self.instanceSelection.currentIndexChanged[int].connect(self.instanceSelected)
- self.validateButton.clicked.connect(self.validate)
- self.instanceEdit.textChanged.connect(self.textChanged)
-
- self.validationStatus.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter)
-
- self.schemaSelected(0)
- self.instanceSelected(0)
-
- def schemaSelected(self, index):
- self.instanceSelection.clear()
-
- if index == 0:
- self.instanceSelection.addItem("Valid Contact Instance")
- self.instanceSelection.addItem("Invalid Contact Instance")
- elif index == 1:
- self.instanceSelection.addItem("Valid Recipe Instance")
- self.instanceSelection.addItem("Invalid Recipe Instance")
- elif index == 2:
- self.instanceSelection.addItem("Valid Order Instance")
- self.instanceSelection.addItem("Invalid Order Instance")
-
- self.textChanged()
-
- schemaFile = QtCore.QFile(':/schema_%d.xsd' % index)
- schemaFile.open(QtCore.QIODevice.ReadOnly)
- schemaData = schemaFile.readAll()
- self.schemaView.setPlainText(encode_utf8(schemaData))
-
- self.validate()
-
- def instanceSelected(self, index):
- if index == -1:
- return
-
- index += 2 * self.schemaSelection.currentIndex()
- instanceFile = QtCore.QFile(':/instance_%d.xml' % index)
- instanceFile.open(QtCore.QIODevice.ReadOnly)
- instanceData = instanceFile.readAll()
- self.instanceEdit.setPlainText(encode_utf8(instanceData))
-
- self.validate()
-
- def validate(self):
- schemaData = decode_utf8(self.schemaView.toPlainText())
- instanceData = decode_utf8(self.instanceEdit.toPlainText())
-
- messageHandler = MessageHandler()
-
- schema = QtXmlPatterns.QXmlSchema()
- schema.setMessageHandler(messageHandler)
- schema.load(schemaData, QtCore.QUrl())
-
- errorOccurred = False
- if not schema.isValid():
- errorOccurred = True
- else:
- validator = QtXmlPatterns.QXmlSchemaValidator(schema)
- if not validator.validate(instanceData):
- errorOccurred = True
-
- if errorOccurred:
- self.validationStatus.setText(messageHandler.statusMessage())
- self.moveCursor(messageHandler.line(), messageHandler.column())
- background = QtCore.Qt.red
- else:
- self.validationStatus.setText("validation successful")
- background = QtCore.Qt.green
-
- styleSheet = 'QLabel {background: %s; padding: 3px}' % QtGui.QColor(background).lighter(160).name()
- self.validationStatus.setStyleSheet(styleSheet)
-
- def textChanged(self):
- self.instanceEdit.setExtraSelections([])
-
- def moveCursor(self, line, column):
- self.instanceEdit.moveCursor(QtGui.QTextCursor.Start)
-
- for i in range(1, line):
- self.instanceEdit.moveCursor(QtGui.QTextCursor.Down)
-
- for i in range(1, column):
- self.instanceEdit.moveCursor(QtGui.QTextCursor.Right)
-
- extraSelections = []
- selection = QtWidgets.QTextEdit.ExtraSelection()
-
- lineColor = QtGui.QColor(QtCore.Qt.red).lighter(160)
- selection.format.setBackground(lineColor)
- selection.format.setProperty(QtGui.QTextFormat.FullWidthSelection, True)
- selection.cursor = self.instanceEdit.textCursor()
- selection.cursor.clearSelection()
- extraSelections.append(selection)
-
- self.instanceEdit.setExtraSelections(extraSelections)
-
- self.instanceEdit.setFocus()
-
-
-if __name__ == '__main__':
-
- import sys
-
- app = QtWidgets.QApplication(sys.argv)
- window = MainWindow()
- window.show()
- sys.exit(app.exec_())
diff --git a/examples/xmlpatterns/schema/schema.pyproject b/examples/xmlpatterns/schema/schema.pyproject
deleted file mode 100644
index 697e58d70..000000000
--- a/examples/xmlpatterns/schema/schema.pyproject
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "files": ["schema.qrc", "schema.py", "schema.ui", "ui_schema.py",
- "schema_rc.py"]
-}
diff --git a/examples/xmlpatterns/schema/schema.qrc b/examples/xmlpatterns/schema/schema.qrc
deleted file mode 100644
index eb7ddfd7c..000000000
--- a/examples/xmlpatterns/schema/schema.qrc
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file alias="schema_0.xsd">files/contact.xsd</file>
- <file alias="schema_1.xsd">files/recipe.xsd</file>
- <file alias="schema_2.xsd">files/order.xsd</file>
- <file alias="instance_0.xml">files/valid_contact.xml</file>
- <file alias="instance_1.xml">files/invalid_contact.xml</file>
- <file alias="instance_2.xml">files/valid_recipe.xml</file>
- <file alias="instance_3.xml">files/invalid_recipe.xml</file>
- <file alias="instance_4.xml">files/valid_order.xml</file>
- <file alias="instance_5.xml">files/invalid_order.xml</file>
-</qresource>
-</RCC>
diff --git a/examples/xmlpatterns/schema/schema.ui b/examples/xmlpatterns/schema/schema.ui
deleted file mode 100644
index b67f444d2..000000000
--- a/examples/xmlpatterns/schema/schema.ui
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>SchemaMainWindow</class>
- <widget class="QMainWindow" name="SchemaMainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>417</width>
- <height>594</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>XML Schema Validation</string>
- </property>
- <widget class="QWidget" name="centralwidget">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="2">
- <widget class="QLabel" name="schemaLabel">
- <property name="text">
- <string>XML Schema Document:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="2" colspan="2">
- <widget class="QComboBox" name="schemaSelection"/>
- </item>
- <item row="1" column="0" colspan="4">
- <widget class="QTextBrowser" name="schemaView"/>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QLabel" name="instanceLabel">
- <property name="text">
- <string>XML Instance Document:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="2" colspan="2">
- <widget class="QComboBox" name="instanceSelection"/>
- </item>
- <item row="3" column="0" colspan="4">
- <widget class="QTextEdit" name="instanceEdit"/>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Status:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1" colspan="2">
- <widget class="QLabel" name="validationStatus">
- <property name="text">
- <string>not validated</string>
- </property>
- </widget>
- </item>
- <item row="4" column="3">
- <widget class="QPushButton" name="validateButton">
- <property name="text">
- <string>Validate</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QStatusBar" name="statusbar"/>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/xmlpatterns/schema/schema_rc.py b/examples/xmlpatterns/schema/schema_rc.py
deleted file mode 100644
index 0c607af97..000000000
--- a/examples/xmlpatterns/schema/schema_rc.py
+++ /dev/null
@@ -1,394 +0,0 @@
-# Resource object code (Python 3)
-# Created by: object code
-# Created by: The Resource Compiler for Qt version 5.14.0
-# WARNING! All changes made in this file will be lost!
-
-from PySide2 import QtCore
-
-qt_resource_data = b"\
-\x00\x00\x01\x81\
-\x00\
-\x00\x06\x05x\x9c\xbdT\xc1r\xc2 \x10\xbd\xfb\x15\x0c\
-\x1f`\xb4\xbd9F\xcf\x9di\xa7\x87\xf6\xd0+\x92\x1d\
-\xc3L\x80\x08\x8b\x89\x7f_\x82\x1am\x0cI\xbc\x94C\
-&\xc3\xbe\xf7\xd8]\x1e\xbb\xde\xd6\xb2 G0Vh\
-\x95\xd2\xe5|A\xb7\x9b\xd9\xba\xb6\xd9\xca\xf2\x1c$#\
->\xae\xec\xcao\xa44G,WIRU\xd5\xbcz\
-\x9dk\xb3O^\x16\x8be\xf2\xf3\xf1\xfe\x15\xb0t3\
-\x9b\x11\xbf\x02\x1d\x0a\x90\xa0\x90(&!\xa5\x06\xb8(\
-\xc1\x03\xc8e\x05\x0c\xd7\xb2,\xa0\xfe>\x95p\x8b\xb4\
-Q\x0b\x07\x07\x8awB\x91\x03P`\x01\x94\xa0\x97J\
-i`\xa3\x11jO\x93Il\x8f4\x90\x09\xbfq\x95\
-\xb8\xed4\xd9Q\x22Y\xfd\xc9\xb936\xa5N\xed\xb4\
-S\x19d\x13\xc5Q\xc86\xb3\xe6?\x08N\xa3J\xc0\
-\x5cg\xf4\x11;\xde\xc2'\xda9\x92\x84E({:\
-;\xb9%\xadt2\x9e\xc6\x193X\xd4\x19rI\xb1\
-c\x9b\xc8\x09\x11\xd5\x8e\xd2\xcd\xbbw\xc8\x07\x83\x84\xdb\
-\xeb\xf8\x98\xa1o\xc9\xce\xe1\x15\xdd|\x87\xbd\xd8K;\
-8\xa6\xbc\x8fO\xf7\xd4R[\x81\xe2\x08o\x0aa\x0f\
-fT\xc3)\x81\xf1\xa3{\x1a1Tu\xeb\xd6\xffJ\
-\xbco\x0a\x88&\xab\x88\x15\x1a\x80\x81\xa6F\x8e~\x80\
-\x91\x1d\xb3\x7f\xeb\x1ex9\xa0\x9c\x04\xc3\x02\xef\xc8\x0a\
-\xd78\x1d\xb8V\x99\x8d\x998F\x93B\xf9:\x9e\xa6\
-\xe5\xda\xbf\x9d\xdeA\x90t\xea\xeauyO_\xce\x91\
-\xb6\xb3\xf1;\xbfH\x84\xa9\xbd\x99\xfd\x02,\xd8\xc0\x1d\
-\
-\x00\x00\x02U\
-<\
-recipe>\x0a <tit\
-le>Cheese on Toa\
-st</title>\x0a <\
-ingredient name=\
-\x22Bread\x22 quantity\
-=\x222\x22 unit=\x22slice\
-s\x22/>\x0a <ingred\
-ient name=\x22Chees\
-e\x22 quantity=\x222\x22 \
-unit=\x22slices\x22/>\x0a\
- <time quanti\
-ty=\x223\x22 unit=\x22day\
-s\x22/>\x0a <method\
->\x0a <step>\
-1. Slice the bre\
-ad and cheese.</\
-step>\x0a <s\
-tep>2. Grill one\
- side of each sl\
-ice of bread.</s\
-tep>\x0a <st\
-ep>3. Turn over \
-the bread and pl\
-ace a slice of c\
-heese on each pi\
-ece.</step>\x0a \
- <step>4. Gri\
-ll until the che\
-ese has started \
-to melt.</step>\x0a\
- <step>5.\
- Serve and enjoy\
-!</step>\x0a </m\
-ethod>\x0a <comm\
-ent>Tell your fr\
-iends about it!<\
-/comment>\x0a</reci\
-pe>\x0a\
-\x00\x00\x03\xbb\
-<\
-?xml version=\x221.\
-0\x22?>\x0a<xsd:schema\
- xmlns:xsd=\x22http\
-://www.w3.org/20\
-01/XMLSchema\x22>\x0a\x0a\
- <xsd:element\
- name=\x22contact\x22>\
-\x0a <xsd:co\
-mplexType>\x0a \
- <xsd:sequ\
-ence>\x0a \
- <xsd:eleme\
-nt name=\x22givenNa\
-me\x22 type=\x22xsd:st\
-ring\x22/>\x0a \
- <xsd:ele\
-ment name=\x22famil\
-yName\x22 type=\x22xsd\
-:string\x22/>\x0a \
- <xsd:\
-element name=\x22bi\
-rthdate\x22 type=\x22x\
-sd:date\x22 minOccu\
-rs=\x220\x22/>\x0a \
- <xsd:el\
-ement name=\x22home\
-Address\x22 type=\x22a\
-ddress\x22/>\x0a \
- <xsd:e\
-lement name=\x22wor\
-kAddress\x22 type=\x22\
-address\x22 minOccu\
-rs=\x220\x22/>\x0a \
- </xsd:seque\
-nce>\x0a </x\
-sd:complexType>\x0a\
- </xsd:elemen\
-t>\x0a\x0a <xsd:com\
-plexType name=\x22a\
-ddress\x22>\x0a \
- <xsd:sequence>\x0a\
- <xsd\
-:element name=\x22s\
-treet\x22 type=\x22xsd\
-:string\x22/>\x0a \
- <xsd:elem\
-ent name=\x22zipCod\
-e\x22 type=\x22xsd:str\
-ing\x22/>\x0a \
- <xsd:element \
-name=\x22city\x22 type\
-=\x22xsd:string\x22/>\x0a\
- <xsd\
-:element name=\x22c\
-ountry\x22 type=\x22xs\
-d:string\x22/>\x0a \
- </xsd:sequen\
-ce>\x0a </xsd:co\
-mplexType>\x0a\x0a</xs\
-d:schema>\x0a\
-\x00\x00\x02%\
-<\
-recipe>\x0a <tit\
-le>Cheese on Toa\
-st</title>\x0a <\
-ingredient name=\
-\x22Bread\x22 quantity\
-=\x222\x22 unit=\x22slice\
-s\x22/>\x0a <ingred\
-ient name=\x22Chees\
-e\x22 quantity=\x222\x22 \
-unit=\x22slices\x22/>\x0a\
- <time quanti\
-ty=\x223\x22 unit=\x22min\
-utes\x22/>\x0a <met\
-hod>\x0a <st\
-ep>1. Slice the \
-bread and cheese\
-.</step>\x0a \
- <step>2. Grill \
-one side of each\
- slice of bread.\
-</step>\x0a \
-<step>3. Turn ov\
-er the bread and\
- place a slice o\
-f cheese on each\
- piece.</step>\x0a \
- <step>4. \
-Grill until the \
-cheese has start\
-ed to melt.</ste\
-p>\x0a <step\
->5. Serve and en\
-joy!</step>\x0a \
-</method>\x0a</reci\
-pe>\x0a\
-\x00\x00\x01\x1d\
-<\
-contact>\x0a <gi\
-venName>John</gi\
-venName>\x0a <fa\
-milyName>Doe</fa\
-milyName>\x0a <t\
-itle>Prof.</titl\
-e>\x0a <workAddr\
-ess>\x0a <st\
-reet>Sandakervei\
-en 116</street>\x0a\
- <zipCode\
->N-0550</zipCode\
->\x0a <city>\
-Oslo</city>\x0a \
- <country>Nor\
-way</country>\x0a \
- </workAddress>\
-\x0a</contact>\x0a\
-\x00\x00\x01.\
-<\
-order>\x0a <cust\
-omerId>234219</c\
-ustomerId>\x0a <\
-article>\x0a \
- <articleId>2169\
-2</articleId>\x0a \
- <count>3</\
-count>\x0a </art\
-icle>\x0a <artic\
-le>\x0a <art\
-icleId>24749</ar\
-ticleId>\x0a \
- <count>9</count\
->\x0a </article>\
-\x0a <deliveryDa\
-te>2009-01-23</d\
-eliveryDate>\x0a \
- <payed>yes</pay\
-ed>\x0a</order>\x0a\
-\x00\x00\x01*\
-<\
-contact>\x0a <gi\
-venName>John</gi\
-venName>\x0a <fa\
-milyName>Doe</fa\
-milyName>\x0a <b\
-irthdate>1977-12\
--25</birthdate>\x0a\
- <homeAddress\
->\x0a <stree\
-t>Sandakerveien \
-116</street>\x0a \
- <zipCode>N-\
-0550</zipCode>\x0a \
- <city>Osl\
-o</city>\x0a \
- <country>Norway\
-</country>\x0a <\
-/homeAddress>\x0a</\
-contact>\x0a\
-\x00\x00\x03g\
-<\
-?xml version=\x221.\
-0\x22?>\x0a<xsd:schema\
- xmlns:xsd=\x22http\
-://www.w3.org/20\
-01/XMLSchema\x22>\x0a\x0a\
- <xsd:element\
- name=\x22order\x22>\x0a \
- <xsd:comp\
-lexType>\x0a \
- <xsd:sequen\
-ce>\x0a \
- <xsd:element\
- name=\x22customerI\
-d\x22 type=\x22xsd:pos\
-itiveInteger\x22/>\x0a\
- \
-<xsd:element nam\
-e=\x22article\x22 type\
-=\x22articleType\x22 m\
-axOccurs=\x22unboun\
-ded\x22/>\x0a \
- <xsd:elem\
-ent name=\x22delive\
-ryDate\x22 type=\x22xs\
-d:date\x22/>\x0a \
- <xsd:e\
-lement name=\x22pay\
-ed\x22 type=\x22xsd:bo\
-olean\x22/>\x0a \
- </xsd:seque\
-nce>\x0a </x\
-sd:complexType>\x0a\
- </xsd:elemen\
-t>\x0a\x0a <xsd:com\
-plexType name=\x22a\
-rticleType\x22>\x0a \
- <xsd:sequen\
-ce>\x0a \
-<xsd:element nam\
-e=\x22articleId\x22 ty\
-pe=\x22xsd:positive\
-Integer\x22/>\x0a \
- <xsd:elem\
-ent name=\x22count\x22\
- type=\x22xsd:posit\
-iveInteger\x22/>\x0a \
- <xsd:e\
-lement name=\x22com\
-ment\x22 type=\x22xsd:\
-string\x22 minOccur\
-s=\x220\x22/>\x0a \
-</xsd:sequence>\x0a\
- </xsd:comple\
-xType>\x0a\x0a</xsd:sc\
-hema>\x0a\
-\x00\x00\x01\xb6\
-<\
-order>\x0a <cust\
-omerId>194223</c\
-ustomerId>\x0a <\
-article>\x0a \
- <articleId>2224\
-2</articleId>\x0a \
- <count>5</\
-count>\x0a </art\
-icle>\x0a <artic\
-le>\x0a <art\
-icleId>32372</ar\
-ticleId>\x0a \
- <count>12</coun\
-t>\x0a <comm\
-ent>without stri\
-pes</comment>\x0a \
- </article>\x0a \
- <article>\x0a \
- <articleId>23\
-649</articleId>\x0a\
- <count>2\
-</count>\x0a </a\
-rticle>\x0a <del\
-iveryDate>2009-0\
-1-23</deliveryDa\
-te>\x0a <payed>t\
-rue</payed>\x0a</or\
-der>\x0a\
-"
-
-qt_resource_name = b"\
-\x00\x0c\
-\x08\x13\x87\xf4\
-\x00s\
-\x00c\x00h\x00e\x00m\x00a\x00_\x001\x00.\x00x\x00s\x00d\
-\x00\x0e\
-\x00sJ\x1c\
-\x00i\
-\x00n\x00s\x00t\x00a\x00n\x00c\x00e\x00_\x003\x00.\x00x\x00m\x00l\
-\x00\x0c\
-\x08\x10\x87\xf4\
-\x00s\
-\x00c\x00h\x00e\x00m\x00a\x00_\x000\x00.\x00x\x00s\x00d\
-\x00\x0e\
-\x00pJ\x1c\
-\x00i\
-\x00n\x00s\x00t\x00a\x00n\x00c\x00e\x00_\x002\x00.\x00x\x00m\x00l\
-\x00\x0e\
-\x00yJ\x1c\
-\x00i\
-\x00n\x00s\x00t\x00a\x00n\x00c\x00e\x00_\x001\x00.\x00x\x00m\x00l\
-\x00\x0e\
-\x00uJ\x1c\
-\x00i\
-\x00n\x00s\x00t\x00a\x00n\x00c\x00e\x00_\x005\x00.\x00x\x00m\x00l\
-\x00\x0e\
-\x00vJ\x1c\
-\x00i\
-\x00n\x00s\x00t\x00a\x00n\x00c\x00e\x00_\x000\x00.\x00x\x00m\x00l\
-\x00\x0c\
-\x08\x16\x87\xf4\
-\x00s\
-\x00c\x00h\x00e\x00m\x00a\x00_\x002\x00.\x00x\x00s\x00d\
-\x00\x0e\
-\x00rJ\x1c\
-\x00i\
-\x00n\x00s\x00t\x00a\x00n\x00c\x00e\x00_\x004\x00.\x00x\x00m\x00l\
-"
-
-qt_resource_struct = b"\
-\x00\x00\x00\x00\x00\x02\x00\x00\x00\x09\x00\x00\x00\x01\
-\x00\x00\x00\x00\x00\x00\x00\x00\
-\x00\x00\x00^\x00\x00\x00\x00\x00\x01\x00\x00\x07\x9d\
-\x00\x00\x01e\xaf\x16\xd2\xa1\
-\x00\x00\x01\x04\x00\x00\x00\x00\x00\x01\x00\x00\x10\xb2\
-\x00\x00\x01e\xaf\x16\xd2\xa1\
-\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x01\x00\x00\x01\x85\
-\x00\x00\x01e\xaf\x16\xd2\xa1\
-\x00\x00\x00\xa2\x00\x00\x00\x00\x00\x01\x00\x00\x0a\xe7\
-\x00\x00\x01e\xaf\x16\xd2\xa1\
-\x00\x00\x00\xc4\x00\x00\x00\x00\x00\x01\x00\x00\x0c\x19\
-\x00\x00\x01e\xaf\x16\xd2\xa1\
-\x00\x00\x00\x80\x00\x00\x00\x00\x00\x01\x00\x00\x09\xc6\
-\x00\x00\x01e\xaf\x16\xd2\xa1\
-\x00\x00\x00@\x00\x00\x00\x00\x00\x01\x00\x00\x03\xde\
-\x00\x00\x01e\xaf\x16\xd2\xa1\
-\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\
-\x00\x00\x01e\xaf\x16\xd2\xa1\
-\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x01\x00\x00\x0dG\
-\x00\x00\x01e\xaf\x16\xd2\xa1\
-"
-
-def qInitResources():
- QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
-
-def qCleanupResources():
- QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
-
-qInitResources()
diff --git a/examples/xmlpatterns/schema/ui_schema.py b/examples/xmlpatterns/schema/ui_schema.py
deleted file mode 100644
index f9cc751eb..000000000
--- a/examples/xmlpatterns/schema/ui_schema.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# -*- coding: utf-8 -*-
-
-################################################################################
-## Form generated from reading UI file 'schema.ui'
-##
-## Created by: Qt User Interface Compiler version 5.14.0
-##
-## WARNING! All changes made in this file will be lost when recompiling UI file!
-################################################################################
-
-from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint,
- QRect, QSize, QUrl, Qt)
-from PySide2.QtGui import (QColor, QFont, QIcon, QPixmap)
-from PySide2.QtWidgets import *
-
-class Ui_SchemaMainWindow(object):
- def setupUi(self, SchemaMainWindow):
- if SchemaMainWindow.objectName():
- SchemaMainWindow.setObjectName(u"SchemaMainWindow")
- SchemaMainWindow.resize(417, 594)
- self.centralwidget = QWidget(SchemaMainWindow)
- self.centralwidget.setObjectName(u"centralwidget")
- self.gridLayout = QGridLayout(self.centralwidget)
- self.gridLayout.setObjectName(u"gridLayout")
- self.schemaLabel = QLabel(self.centralwidget)
- self.schemaLabel.setObjectName(u"schemaLabel")
-
- self.gridLayout.addWidget(self.schemaLabel, 0, 0, 1, 2)
-
- self.schemaSelection = QComboBox(self.centralwidget)
- self.schemaSelection.setObjectName(u"schemaSelection")
-
- self.gridLayout.addWidget(self.schemaSelection, 0, 2, 1, 2)
-
- self.schemaView = QTextBrowser(self.centralwidget)
- self.schemaView.setObjectName(u"schemaView")
-
- self.gridLayout.addWidget(self.schemaView, 1, 0, 1, 4)
-
- self.instanceLabel = QLabel(self.centralwidget)
- self.instanceLabel.setObjectName(u"instanceLabel")
-
- self.gridLayout.addWidget(self.instanceLabel, 2, 0, 1, 2)
-
- self.instanceSelection = QComboBox(self.centralwidget)
- self.instanceSelection.setObjectName(u"instanceSelection")
-
- self.gridLayout.addWidget(self.instanceSelection, 2, 2, 1, 2)
-
- self.instanceEdit = QTextEdit(self.centralwidget)
- self.instanceEdit.setObjectName(u"instanceEdit")
-
- self.gridLayout.addWidget(self.instanceEdit, 3, 0, 1, 4)
-
- self.label = QLabel(self.centralwidget)
- self.label.setObjectName(u"label")
-
- self.gridLayout.addWidget(self.label, 4, 0, 1, 1)
-
- self.validationStatus = QLabel(self.centralwidget)
- self.validationStatus.setObjectName(u"validationStatus")
-
- self.gridLayout.addWidget(self.validationStatus, 4, 1, 1, 2)
-
- self.validateButton = QPushButton(self.centralwidget)
- self.validateButton.setObjectName(u"validateButton")
-
- self.gridLayout.addWidget(self.validateButton, 4, 3, 1, 1)
-
- SchemaMainWindow.setCentralWidget(self.centralwidget)
- self.statusbar = QStatusBar(SchemaMainWindow)
- self.statusbar.setObjectName(u"statusbar")
- SchemaMainWindow.setStatusBar(self.statusbar)
-
- self.retranslateUi(SchemaMainWindow)
-
- QMetaObject.connectSlotsByName(SchemaMainWindow)
- # setupUi
-
- def retranslateUi(self, SchemaMainWindow):
- SchemaMainWindow.setWindowTitle(QCoreApplication.translate("SchemaMainWindow", u"XML Schema Validation", None))
- self.schemaLabel.setText(QCoreApplication.translate("SchemaMainWindow", u"XML Schema Document:", None))
- self.instanceLabel.setText(QCoreApplication.translate("SchemaMainWindow", u"XML Instance Document:", None))
- self.label.setText(QCoreApplication.translate("SchemaMainWindow", u"Status:", None))
- self.validationStatus.setText(QCoreApplication.translate("SchemaMainWindow", u"not validated", None))
- self.validateButton.setText(QCoreApplication.translate("SchemaMainWindow", u"Validate", None))
- # retranslateUi
-