diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-12-20 08:35:46 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-01-06 11:52:18 +0100 |
| commit | 7189a4c5ec193d30c6bd4e68701038880cbc5982 (patch) | |
| tree | 87e4ec00d7e9d31e5df0c11b155e46ffd3726362 /examples/graphs | |
| parent | ab8b330123cb557f66306b237f4c3aa8c0004f39 (diff) | |
Use fully qualified enumerations in more examples
Pick-to: 6.8
Task-number: PYSIDE-1735
Change-Id: Ic2c478ef363d73f65f366e21529c0429c86539aa
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/graphs')
9 files changed, 74 insertions, 74 deletions
diff --git a/examples/graphs/3d/bars/main.py b/examples/graphs/3d/bars/main.py index 0a75de48d..3bd3d2bb3 100644 --- a/examples/graphs/3d/bars/main.py +++ b/examples/graphs/3d/bars/main.py @@ -15,7 +15,7 @@ if __name__ == '__main__': view.engine().addImportPath(Path(__file__).parent) view.loadFromModule("Bars", "Main") view.setTitle("Monthly income / expenses") - view.setResizeMode(QQuickView.SizeRootObjectToView) + view.setResizeMode(QQuickView.ResizeMode.SizeRootObjectToView) view.setColor("black") view.show() diff --git a/examples/graphs/3d/widgetgraphgallery/bargraph.py b/examples/graphs/3d/widgetgraphgallery/bargraph.py index 4f117d911..3259e8a33 100644 --- a/examples/graphs/3d/widgetgraphgallery/bargraph.py +++ b/examples/graphs/3d/widgetgraphgallery/bargraph.py @@ -26,8 +26,8 @@ class BarGraph(QObject): hLayout = QHBoxLayout(self._barsWidget) barsGraphWidget.setMinimumSize(minimum_graph_size) barsGraphWidget.setMaximumSize(maximum_graph_size) - barsGraphWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - barsGraphWidget.setFocusPolicy(Qt.StrongFocus) + barsGraphWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) + barsGraphWidget.setFocusPolicy(Qt.FocusPolicy.StrongFocus) hLayout.addWidget(barsGraphWidget, 1) vLayout = QVBoxLayout() @@ -119,20 +119,20 @@ class BarGraph(QObject): rotationSliderX = QSlider(Qt.Orientation.Horizontal, self._barsWidget) rotationSliderX.setTickInterval(30) - rotationSliderX.setTickPosition(QSlider.TicksBelow) + rotationSliderX.setTickPosition(QSlider.TickPosition.TicksBelow) rotationSliderX.setMinimum(-180) rotationSliderX.setValue(0) rotationSliderX.setMaximum(180) rotationSliderY = QSlider(Qt.Orientation.Horizontal, self._barsWidget) rotationSliderY.setTickInterval(15) - rotationSliderY.setTickPosition(QSlider.TicksAbove) + rotationSliderY.setTickPosition(QSlider.TickPosition.TicksAbove) rotationSliderY.setMinimum(-90) rotationSliderY.setValue(0) rotationSliderY.setMaximum(90) fontSizeSlider = QSlider(Qt.Orientation.Horizontal, self._barsWidget) fontSizeSlider.setTickInterval(10) - fontSizeSlider.setTickPosition(QSlider.TicksBelow) + fontSizeSlider.setTickPosition(QSlider.TickPosition.TicksBelow) fontSizeSlider.setMinimum(1) fontSizeSlider.setValue(30) fontSizeSlider.setMaximum(100) @@ -172,7 +172,7 @@ class BarGraph(QObject): axisLabelRotationSlider = QSlider(Qt.Orientation.Horizontal, self._barsWidget) axisLabelRotationSlider.setTickInterval(10) - axisLabelRotationSlider.setTickPosition(QSlider.TicksBelow) + axisLabelRotationSlider.setTickPosition(QSlider.TickPosition.TicksBelow) axisLabelRotationSlider.setMinimum(0) axisLabelRotationSlider.setValue(30) axisLabelRotationSlider.setMaximum(90) @@ -185,12 +185,12 @@ class BarGraph(QObject): modeGroup.addButton(modeCustomProxy) vLayout.addWidget(QLabel("Rotate horizontally")) - vLayout.addWidget(rotationSliderX, 0, Qt.AlignTop) + vLayout.addWidget(rotationSliderX, 0, Qt.AlignmentFlag.AlignTop) vLayout.addWidget(QLabel("Rotate vertically")) - vLayout.addWidget(rotationSliderY, 0, Qt.AlignTop) - vLayout.addWidget(labelButton, 0, Qt.AlignTop) - vLayout.addWidget(cameraButton, 0, Qt.AlignTop) - vLayout.addWidget(zoomToSelectedButton, 0, Qt.AlignTop) + vLayout.addWidget(rotationSliderY, 0, Qt.AlignmentFlag.AlignTop) + vLayout.addWidget(labelButton, 0, Qt.AlignmentFlag.AlignTop) + vLayout.addWidget(cameraButton, 0, Qt.AlignmentFlag.AlignTop) + vLayout.addWidget(zoomToSelectedButton, 0, Qt.AlignmentFlag.AlignTop) vLayout.addWidget(backgroundCheckBox) vLayout.addWidget(gridCheckBox) vLayout.addWidget(smoothCheckBox) @@ -213,9 +213,9 @@ class BarGraph(QObject): vLayout.addWidget(QLabel("Adjust font size")) vLayout.addWidget(fontSizeSlider) vLayout.addWidget(QLabel("Axis label rotation")) - vLayout.addWidget(axisLabelRotationSlider, 0, Qt.AlignTop) - vLayout.addWidget(modeWeather, 0, Qt.AlignTop) - vLayout.addWidget(modeCustomProxy, 1, Qt.AlignTop) + vLayout.addWidget(axisLabelRotationSlider, 0, Qt.AlignmentFlag.AlignTop) + vLayout.addWidget(modeWeather, 0, Qt.AlignmentFlag.AlignTop) + vLayout.addWidget(modeCustomProxy, 1, Qt.AlignmentFlag.AlignTop) modifier = GraphModifier(barsGraph, self) modifier.changeTheme(themeList.currentIndex()) diff --git a/examples/graphs/3d/widgetgraphgallery/highlightseries.py b/examples/graphs/3d/widgetgraphgallery/highlightseries.py index e6e1af3df..27dad4705 100644 --- a/examples/graphs/3d/widgetgraphgallery/highlightseries.py +++ b/examples/graphs/3d/widgetgraphgallery/highlightseries.py @@ -26,7 +26,7 @@ class HighlightSeries(QSurface3DSeries): self._position = {} self._topographicSeries = None self._minHeight = 0.0 - self.setDrawMode(QSurface3DSeries.DrawSurface) + self.setDrawMode(QSurface3DSeries.DrawFlag.DrawSurface) self.setShading(QSurface3DSeries.Shading.Flat) self.setVisible(False) @@ -84,12 +84,12 @@ class HighlightSeries(QSurface3DSeries): ratio = self._minHeight / value gr = QLinearGradient() - gr.setColorAt(0.0, Qt.black) - gr.setColorAt(DARK_GREEN_POS * ratio, Qt.darkGreen) - gr.setColorAt(GREEN_POS * ratio, Qt.green) - gr.setColorAt(YELLOW_POS * ratio, Qt.yellow) - gr.setColorAt(RED_POS * ratio, Qt.red) - gr.setColorAt(DARK_RED_POS * ratio, Qt.darkRed) + gr.setColorAt(0.0, Qt.GlobalColor.black) + gr.setColorAt(DARK_GREEN_POS * ratio, Qt.GlobalColor.darkGreen) + gr.setColorAt(GREEN_POS * ratio, Qt.GlobalColor.green) + gr.setColorAt(YELLOW_POS * ratio, Qt.GlobalColor.yellow) + gr.setColorAt(RED_POS * ratio, Qt.GlobalColor.red) + gr.setColorAt(DARK_RED_POS * ratio, Qt.GlobalColor.darkRed) self.setBaseGradient(gr) self.setColorStyle(QGraphsTheme.ColorStyle.RangeGradient) diff --git a/examples/graphs/3d/widgetgraphgallery/rainfalldata.py b/examples/graphs/3d/widgetgraphgallery/rainfalldata.py index 283b421e7..a5339672e 100644 --- a/examples/graphs/3d/widgetgraphgallery/rainfalldata.py +++ b/examples/graphs/3d/widgetgraphgallery/rainfalldata.py @@ -96,7 +96,7 @@ class RainfallData(QObject): # Read data from a data file into the data item list file_path = Path(__file__).resolve().parent / "data" / "raindata.txt" dataFile = QFile(file_path) - if dataFile.open(QIODevice.ReadOnly | QIODevice.Text): + if dataFile.open(QIODevice.OpenModeFlag.ReadOnly | QIODevice.OpenModeFlag.Text): data = dataFile.readAll().data().decode("utf8") for line in data.split("\n"): if line and not line.startswith("#"): # Ignore comments diff --git a/examples/graphs/3d/widgetgraphgallery/scatterdatamodifier.py b/examples/graphs/3d/widgetgraphgallery/scatterdatamodifier.py index 1dd7db84b..946c96261 100644 --- a/examples/graphs/3d/widgetgraphgallery/scatterdatamodifier.py +++ b/examples/graphs/3d/widgetgraphgallery/scatterdatamodifier.py @@ -60,7 +60,7 @@ class ScatterDataModifier(QObject): self._graph.selectedElementChanged.connect(self.handleElementSelected) self._graph.dragged.connect(self.handleAxisDragging) - self._graph.setDragButton(Qt.LeftButton) + self._graph.setDragButton(Qt.MouseButton.LeftButton) self.addData() diff --git a/examples/graphs/3d/widgetgraphgallery/scattergraph.py b/examples/graphs/3d/widgetgraphgallery/scattergraph.py index 00b7fff69..1b5c507a9 100644 --- a/examples/graphs/3d/widgetgraphgallery/scattergraph.py +++ b/examples/graphs/3d/widgetgraphgallery/scattergraph.py @@ -25,8 +25,8 @@ class ScatterGraph(QObject): hLayout = QHBoxLayout(self._scatterWidget) scatterGraphWidget.setMinimumSize(minimum_graph_size) scatterGraphWidget.setMaximumSize(maximum_graph_size) - scatterGraphWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - scatterGraphWidget.setFocusPolicy(Qt.StrongFocus) + scatterGraphWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) + scatterGraphWidget.setFocusPolicy(Qt.FocusPolicy.StrongFocus) hLayout.addWidget(scatterGraphWidget, 1) vLayout = QVBoxLayout() @@ -98,7 +98,7 @@ class ScatterGraph(QObject): vLayout.addWidget(QLabel("Change theme")) vLayout.addWidget(themeList) vLayout.addWidget(QLabel("Adjust shadow quality")) - vLayout.addWidget(shadowQuality, 1, Qt.AlignTop) + vLayout.addWidget(shadowQuality, 1, Qt.AlignmentFlag.AlignTop) modifier = ScatterDataModifier(scatterGraph, self) diff --git a/examples/graphs/3d/widgetgraphgallery/surfacegraph.py b/examples/graphs/3d/widgetgraphgallery/surfacegraph.py index 8457251ed..8d565f9e0 100644 --- a/examples/graphs/3d/widgetgraphgallery/surfacegraph.py +++ b/examples/graphs/3d/widgetgraphgallery/surfacegraph.py @@ -15,28 +15,28 @@ from PySide6.QtGraphsWidgets import Q3DSurfaceWidgetItem def gradientBtoYPB_Pixmap(): grBtoY = QLinearGradient(0, 0, 1, 100) - grBtoY.setColorAt(1.0, Qt.black) - grBtoY.setColorAt(0.67, Qt.blue) - grBtoY.setColorAt(0.33, Qt.red) - grBtoY.setColorAt(0.0, Qt.yellow) + grBtoY.setColorAt(1.0, Qt.GlobalColor.black) + grBtoY.setColorAt(0.67, Qt.GlobalColor.blue) + grBtoY.setColorAt(0.33, Qt.GlobalColor.red) + grBtoY.setColorAt(0.0, Qt.GlobalColor.yellow) pm = QPixmap(24, 100) with QPainter(pm) as pmp: pmp.setBrush(QBrush(grBtoY)) - pmp.setPen(Qt.NoPen) + pmp.setPen(Qt.PenStyle.NoPen) pmp.drawRect(0, 0, 24, 100) return pm def gradientGtoRPB_Pixmap(): grGtoR = QLinearGradient(0, 0, 1, 100) - grGtoR.setColorAt(1.0, Qt.darkGreen) - grGtoR.setColorAt(0.5, Qt.yellow) - grGtoR.setColorAt(0.2, Qt.red) - grGtoR.setColorAt(0.0, Qt.darkRed) + grGtoR.setColorAt(1.0, Qt.GlobalColor.darkGreen) + grGtoR.setColorAt(0.5, Qt.GlobalColor.yellow) + grGtoR.setColorAt(0.2, Qt.GlobalColor.red) + grGtoR.setColorAt(0.0, Qt.GlobalColor.darkRed) pm = QPixmap(24, 100) with QPainter(pm) as pmp: pmp.setBrush(QBrush(grGtoR)) - pmp.setPen(Qt.NoPen) + pmp.setPen(Qt.PenStyle.NoPen) pmp.drawRect(0, 0, 24, 100) return pm @@ -46,19 +46,19 @@ def highlightPixmap(): WIDTH = 110 BORDER = 10 gr = QLinearGradient(0, 0, 1, HEIGHT - 2 * BORDER) - gr.setColorAt(1.0, Qt.black) - gr.setColorAt(0.8, Qt.darkGreen) - gr.setColorAt(0.6, Qt.green) - gr.setColorAt(0.4, Qt.yellow) - gr.setColorAt(0.2, Qt.red) - gr.setColorAt(0.0, Qt.darkRed) + gr.setColorAt(1.0, Qt.GlobalColor.black) + gr.setColorAt(0.8, Qt.GlobalColor.darkGreen) + gr.setColorAt(0.6, Qt.GlobalColor.green) + gr.setColorAt(0.4, Qt.GlobalColor.yellow) + gr.setColorAt(0.2, Qt.GlobalColor.red) + gr.setColorAt(0.0, Qt.GlobalColor.darkRed) pmHighlight = QPixmap(WIDTH, HEIGHT) - pmHighlight.fill(Qt.transparent) + pmHighlight.fill(Qt.GlobalColor.transparent) with QPainter(pmHighlight) as pmpHighlight: pmpHighlight.setBrush(QBrush(gr)) - pmpHighlight.setPen(Qt.NoPen) + pmpHighlight.setPen(Qt.PenStyle.NoPen) pmpHighlight.drawRect(BORDER, BORDER, 35, HEIGHT - 2 * BORDER) - pmpHighlight.setPen(Qt.black) + pmpHighlight.setPen(Qt.GlobalColor.black) step = (HEIGHT - 2 * BORDER) / 5 for i in range(0, 6): yPos = i * step + BORDER @@ -80,13 +80,13 @@ class SurfaceGraph(QObject): hLayout = QHBoxLayout(self._surfaceWidget) surfaceGraphWidget.setMinimumSize(minimum_graph_size) surfaceGraphWidget.setMaximumSize(maximum_graph_size) - surfaceGraphWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - surfaceGraphWidget.setFocusPolicy(Qt.StrongFocus) - surfaceGraphWidget.setResizeMode(QQuickWidget.SizeRootObjectToView) + surfaceGraphWidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) + surfaceGraphWidget.setFocusPolicy(Qt.FocusPolicy.StrongFocus) + surfaceGraphWidget.setResizeMode(QQuickWidget.ResizeMode.SizeRootObjectToView) hLayout.addWidget(surfaceGraphWidget, 1) vLayout = QVBoxLayout() hLayout.addLayout(vLayout) - vLayout.setAlignment(Qt.AlignTop) + vLayout.setAlignment(Qt.AlignmentFlag.AlignTop) # Create control widgets modelGroupBox = QGroupBox("Model") sqrtSinModelRB = QRadioButton(self._surfaceWidget) diff --git a/examples/graphs/3d/widgetgraphgallery/surfacegraphmodifier.py b/examples/graphs/3d/widgetgraphgallery/surfacegraphmodifier.py index 74bab3491..d9b2126fb 100644 --- a/examples/graphs/3d/widgetgraphgallery/surfacegraphmodifier.py +++ b/examples/graphs/3d/widgetgraphgallery/surfacegraphmodifier.py @@ -140,23 +140,23 @@ class SurfaceGraphModifier(QObject): # Set the gradients for multi-surface layers grOne = QLinearGradient() - grOne.setColorAt(0.0, Qt.black) - grOne.setColorAt(0.38, Qt.darkYellow) - grOne.setColorAt(0.39, Qt.darkGreen) - grOne.setColorAt(0.5, Qt.darkGray) - grOne.setColorAt(1.0, Qt.gray) + grOne.setColorAt(0.0, Qt.GlobalColor.black) + grOne.setColorAt(0.38, Qt.GlobalColor.darkYellow) + grOne.setColorAt(0.39, Qt.GlobalColor.darkGreen) + grOne.setColorAt(0.5, Qt.GlobalColor.darkGray) + grOne.setColorAt(1.0, Qt.GlobalColor.gray) self._heightMapSeriesOne.setBaseGradient(grOne) self._heightMapSeriesOne.setColorStyle(QGraphsTheme.ColorStyle.RangeGradient) grTwo = QLinearGradient() - grTwo.setColorAt(0.39, Qt.blue) - grTwo.setColorAt(0.4, Qt.white) + grTwo.setColorAt(0.39, Qt.GlobalColor.blue) + grTwo.setColorAt(0.4, Qt.GlobalColor.white) self._heightMapSeriesTwo.setBaseGradient(grTwo) self._heightMapSeriesTwo.setColorStyle(QGraphsTheme.ColorStyle.RangeGradient) grThree = QLinearGradient() - grThree.setColorAt(0.0, Qt.white) - grThree.setColorAt(0.05, Qt.black) + grThree.setColorAt(0.0, Qt.GlobalColor.white) + grThree.setColorAt(0.05, Qt.GlobalColor.black) self._heightMapSeriesThree.setBaseGradient(grThree) self._heightMapSeriesThree.setColorStyle(QGraphsTheme.ColorStyle.RangeGradient) @@ -223,7 +223,7 @@ class SurfaceGraphModifier(QObject): @Slot(bool) def enableSqrtSinModel(self, enable): if enable: - self._sqrtSinSeries.setDrawMode(QSurface3DSeries.DrawSurfaceAndWireframe) + self._sqrtSinSeries.setDrawMode(QSurface3DSeries.DrawFlag.DrawSurfaceAndWireframe) self._sqrtSinSeries.setShading(QSurface3DSeries.Shading.Flat) self._graph.axisX().setLabelFormat("%.2f") @@ -275,11 +275,11 @@ class SurfaceGraphModifier(QObject): @Slot(bool) def enableHeightMapModel(self, enable): if enable: - self._heightMapSeriesOne.setDrawMode(QSurface3DSeries.DrawSurface) + self._heightMapSeriesOne.setDrawMode(QSurface3DSeries.DrawFlag.DrawSurface) self._heightMapSeriesOne.setShading(QSurface3DSeries.Shading.Flat) - self._heightMapSeriesTwo.setDrawMode(QSurface3DSeries.DrawSurface) + self._heightMapSeriesTwo.setDrawMode(QSurface3DSeries.DrawFlag.DrawSurface) self._heightMapSeriesTwo.setShading(QSurface3DSeries.Shading.Flat) - self._heightMapSeriesThree.setDrawMode(QSurface3DSeries.DrawSurface) + self._heightMapSeriesThree.setDrawMode(QSurface3DSeries.DrawFlag.DrawSurface) self._heightMapSeriesThree.setShading(QSurface3DSeries.Shading.Flat) self._graph.axisX().setLabelFormat("%.1f N") @@ -443,7 +443,7 @@ class SurfaceGraphModifier(QObject): def setBlackToYellowGradient(self): gr = QLinearGradient() - gr.setColorAt(0.0, Qt.black) + gr.setColorAt(0.0, Qt.GlobalColor.black) gr.setColorAt(0.33, Qt.blue) gr.setColorAt(0.67, Qt.red) gr.setColorAt(1.0, Qt.yellow) @@ -467,8 +467,8 @@ class SurfaceGraphModifier(QObject): positionOnePipe = QVector3D(39.0, 45.0, 19.2) positionOneLabel = QVector3D(39.0, 107.0, 19.2) if show: - color = QImage(2, 2, QImage.Format_RGB32) - color.fill(Qt.red) + color = QImage(2, 2, QImage.Format.Format_RGB32) + color.fill(Qt.GlobalColor.red) file_name = os.fspath(self._data_path / "oilrig.mesh") item = QCustom3DItem(file_name, positionOne, QVector3D(0.025, 0.025, 0.025), @@ -499,8 +499,8 @@ class SurfaceGraphModifier(QObject): positionTwoPipe = QVector3D(34.5, 45.0, 23.4) positionTwoLabel = QVector3D(34.5, 107.0, 23.4) if show: - color = QImage(2, 2, QImage.Format_RGB32) - color.fill(Qt.red) + color = QImage(2, 2, QImage.Format.Format_RGB32) + color.fill(Qt.GlobalColor.red) item = QCustom3DItem() file_name = os.fspath(self._data_path / "oilrig.mesh") item.setMeshFile(file_name) @@ -532,7 +532,7 @@ class SurfaceGraphModifier(QObject): positionThree = QVector3D(34.5, 86.0, 19.1) positionThreeLabel = QVector3D(34.5, 116.0, 19.1) if show: - color = QImage(2, 2, QImage.Format_RGB32) + color = QImage(2, 2, QImage.Format.Format_RGB32) color.fill(Qt.darkMagenta) item = QCustom3DItem() file_name = os.fspath(self._data_path / "refinery.mesh") @@ -569,13 +569,13 @@ class SurfaceGraphModifier(QObject): s2 = self._graph.seriesList()[2] if highlight: grThree = QLinearGradient() - grThree.setColorAt(0.0, Qt.black) + grThree.setColorAt(0.0, Qt.GlobalColor.black) grThree.setColorAt(0.05, Qt.red) s2.setBaseGradient(grThree) else: grThree = QLinearGradient() - grThree.setColorAt(0.0, Qt.white) - grThree.setColorAt(0.05, Qt.black) + grThree.setColorAt(0.0, Qt.GlobalColor.white) + grThree.setColorAt(0.05, Qt.GlobalColor.black) s2.setBaseGradient(grThree) @Slot(bool) diff --git a/examples/graphs/3d/widgetgraphgallery/topographicseries.py b/examples/graphs/3d/widgetgraphgallery/topographicseries.py index 69a58c6b5..41cc35a36 100644 --- a/examples/graphs/3d/widgetgraphgallery/topographicseries.py +++ b/examples/graphs/3d/widgetgraphgallery/topographicseries.py @@ -17,9 +17,9 @@ class TopographicSeries(QSurface3DSeries): super().__init__() self._sampleCountX = 0.0 self._sampleCountZ = 0.0 - self.setDrawMode(QSurface3DSeries.DrawSurface) + self.setDrawMode(QSurface3DSeries.DrawFlag.DrawSurface) self.setShading(QSurface3DSeries.Shading.Flat) - self.setBaseColor(Qt.white) + self.setBaseColor(Qt.GlobalColor.white) def sampleCountX(self): return self._sampleCountX |
