aboutsummaryrefslogtreecommitdiffstats
path: root/examples/graphs
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-09-18 10:33:50 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-09-18 20:11:10 +0200
commitfe5020b7e218078562c6b9b35d005553f53255fb (patch)
tree3b362d3a228e0b331771d9816474d0cdf60286df /examples/graphs
parent496ffda6aa0915ce6982093290aa565b8b464348 (diff)
widgetgraphgallery: Fix up and port away from deprecated QCheckBox::checkStateChanged()
Adapt to qtbase/3512fb1ec5ff088772170540c4e91b1886fbea45 . Remove obsolete options and adapt to some API changes. Task-number: PYSIDE-2620 Change-Id: I11738858cc9107129c0d0137043bae65d8cb4ac9 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'examples/graphs')
-rw-r--r--examples/graphs/3d/widgetgraphgallery/bargraph.py20
-rw-r--r--examples/graphs/3d/widgetgraphgallery/graphmodifier.py32
-rw-r--r--examples/graphs/3d/widgetgraphgallery/scatterdatamodifier.py11
-rw-r--r--examples/graphs/3d/widgetgraphgallery/scattergraph.py6
-rw-r--r--examples/graphs/3d/widgetgraphgallery/surfacegraph.py14
-rw-r--r--examples/graphs/3d/widgetgraphgallery/surfacegraphmodifier.py10
6 files changed, 44 insertions, 49 deletions
diff --git a/examples/graphs/3d/widgetgraphgallery/bargraph.py b/examples/graphs/3d/widgetgraphgallery/bargraph.py
index 24a6541fb..4f117d911 100644
--- a/examples/graphs/3d/widgetgraphgallery/bargraph.py
+++ b/examples/graphs/3d/widgetgraphgallery/bargraph.py
@@ -117,10 +117,6 @@ class BarGraph(QObject):
reverseValueAxisCheckBox.setText("Reverse value axis")
reverseValueAxisCheckBox.setChecked(False)
- reflectionCheckBox = QCheckBox(self._barsWidget)
- reflectionCheckBox.setText("Show reflections")
- reflectionCheckBox.setChecked(False)
-
rotationSliderX = QSlider(Qt.Orientation.Horizontal, self._barsWidget)
rotationSliderX.setTickInterval(30)
rotationSliderX.setTickPosition(QSlider.TicksBelow)
@@ -198,7 +194,6 @@ class BarGraph(QObject):
vLayout.addWidget(backgroundCheckBox)
vLayout.addWidget(gridCheckBox)
vLayout.addWidget(smoothCheckBox)
- vLayout.addWidget(reflectionCheckBox)
vLayout.addWidget(seriesCheckBox)
vLayout.addWidget(reverseValueAxisCheckBox)
vLayout.addWidget(axisTitlesVisibleCB)
@@ -232,12 +227,11 @@ class BarGraph(QObject):
cameraButton.clicked.connect(modifier.changePresetCamera)
zoomToSelectedButton.clicked.connect(modifier.zoomToSelectedBar)
- backgroundCheckBox.stateChanged.connect(modifier.setPlotAreaBackgroundVisible)
- gridCheckBox.stateChanged.connect(modifier.setGridVisible)
- smoothCheckBox.stateChanged.connect(modifier.setSmoothBars)
- seriesCheckBox.stateChanged.connect(modifier.setSeriesVisibility)
- reverseValueAxisCheckBox.stateChanged.connect(modifier.setReverseValueAxis)
- reflectionCheckBox.stateChanged.connect(modifier.setReflection)
+ backgroundCheckBox.checkStateChanged.connect(modifier.setPlotAreaBackgroundVisible)
+ gridCheckBox.checkStateChanged.connect(modifier.setGridVisible)
+ smoothCheckBox.checkStateChanged.connect(modifier.setSmoothBars)
+ seriesCheckBox.checkStateChanged.connect(modifier.setSeriesVisibility)
+ reverseValueAxisCheckBox.checkStateChanged.connect(modifier.setReverseValueAxis)
modifier.backgroundVisibleChanged.connect(backgroundCheckBox.setChecked)
modifier.gridVisibleChanged.connect(gridCheckBox.setChecked)
@@ -261,8 +255,8 @@ class BarGraph(QObject):
modifier.fontSizeChanged.connect(fontSizeSlider.setValue)
modifier.fontChanged.connect(fontList.setCurrentFont)
- axisTitlesVisibleCB.stateChanged.connect(modifier.setAxisTitleVisibility)
- axisTitlesFixedCB.stateChanged.connect(modifier.setAxisTitleFixed)
+ axisTitlesVisibleCB.checkStateChanged.connect(modifier.setAxisTitleVisibility)
+ axisTitlesFixedCB.checkStateChanged.connect(modifier.setAxisTitleFixed)
axisLabelRotationSlider.valueChanged.connect(modifier.changeLabelRotation)
modeWeather.toggled.connect(modifier.setDataModeToWeather)
diff --git a/examples/graphs/3d/widgetgraphgallery/graphmodifier.py b/examples/graphs/3d/widgetgraphgallery/graphmodifier.py
index 8c66cab10..5c4d23c92 100644
--- a/examples/graphs/3d/widgetgraphgallery/graphmodifier.py
+++ b/examples/graphs/3d/widgetgraphgallery/graphmodifier.py
@@ -6,7 +6,7 @@ from __future__ import annotations
from math import atan, degrees
import numpy as np
-from PySide6.QtCore import QObject, QPropertyAnimation, Signal, Slot
+from PySide6.QtCore import QObject, QPropertyAnimation, Qt, Signal, Slot
from PySide6.QtGui import QFont, QVector3D
from PySide6.QtGraphs import (QAbstract3DSeries,
QBarDataItem, QBar3DSeries, QCategory3DAxis,
@@ -258,13 +258,15 @@ class GraphModifier(QObject):
self._yearAxis.setLabelAutoAngle(float(rotation))
@Slot(bool)
- def setAxisTitleVisibility(self, enabled):
+ def setAxisTitleVisibility(self, state):
+ enabled = state == Qt.CheckState.Checked
self._temperatureAxis.setTitleVisible(enabled)
self._monthAxis.setTitleVisible(enabled)
self._yearAxis.setTitleVisible(enabled)
@Slot(bool)
- def setAxisTitleFixed(self, enabled):
+ def setAxisTitleFixed(self, state):
+ enabled = state == Qt.CheckState.Checked
self._temperatureAxis.setTitleFixed(enabled)
self._monthAxis.setTitleFixed(enabled)
self._yearAxis.setTitleFixed(enabled)
@@ -351,26 +353,24 @@ class GraphModifier(QObject):
self._yRotation = rotation
self._graph.setCameraPosition(self._xRotation, self._yRotation)
- def setPlotAreaBackgroundVisible(self, enabled):
- self._graph.activeTheme().setPlotAreaBackgroundVisible(bool(enabled))
+ def setPlotAreaBackgroundVisible(self, state):
+ enabled = state == Qt.CheckState.Checked
+ self._graph.activeTheme().setPlotAreaBackgroundVisible(enabled)
- def setGridVisible(self, enabled):
- self._graph.activeTheme().setGridVisible(bool(enabled))
+ def setGridVisible(self, state):
+ self._graph.activeTheme().setGridVisible(state == Qt.CheckState.Checked)
- def setSmoothBars(self, smooth):
- self._smooth = bool(smooth)
+ def setSmoothBars(self, state):
+ self._smooth = state == Qt.CheckState.Checked
self._primarySeries.setMeshSmooth(self._smooth)
self._secondarySeries.setMeshSmooth(self._smooth)
self._customData.customSeries().setMeshSmooth(self._smooth)
- def setSeriesVisibility(self, enabled):
- self._secondarySeries.setVisible(bool(enabled))
+ def setSeriesVisibility(self, state):
+ self._secondarySeries.setVisible(state == Qt.CheckState.Checked)
- def setReverseValueAxis(self, enabled):
- self._graph.valueAxis().setReversed(enabled)
-
- def setReflection(self, enabled):
- self._graph.setReflection(enabled)
+ def setReverseValueAxis(self, state):
+ self._graph.valueAxis().setReversed(state == Qt.CheckState.Checked)
def changeDataMode(self, customData):
# Change between weather data and data from custom proxy
diff --git a/examples/graphs/3d/widgetgraphgallery/scatterdatamodifier.py b/examples/graphs/3d/widgetgraphgallery/scatterdatamodifier.py
index f66a295e8..1dd7db84b 100644
--- a/examples/graphs/3d/widgetgraphgallery/scatterdatamodifier.py
+++ b/examples/graphs/3d/widgetgraphgallery/scatterdatamodifier.py
@@ -91,7 +91,7 @@ class ScatterDataModifier(QObject):
@Slot(int)
def setSmoothDots(self, smooth):
- self._smooth = smooth == Qt.Checked.value
+ self._smooth = smooth == Qt.CheckState.Checked
series = self._graph.seriesList()[0]
series.setMeshSmooth(self._smooth)
@@ -120,12 +120,13 @@ class ScatterDataModifier(QObject):
self._graph.setShadowQuality(sq)
@Slot(int)
- def setPlotAreaBackgroundVisible(self, enabled):
- self._graph.activeTheme().setPlotAreaBackgroundVisible(enabled == Qt.Checked.value)
+ def setPlotAreaBackgroundVisible(self, state):
+ enabled = state == Qt.CheckState.Checked
+ self._graph.activeTheme().setPlotAreaBackgroundVisible(enabled)
@Slot(int)
- def setGridVisible(self, enabled):
- self._graph.activeTheme().setGridVisible(enabled == Qt.Checked.value)
+ def setGridVisible(self, state):
+ self._graph.activeTheme().setGridVisible(state == Qt.Checked.value)
@Slot()
def toggleItemCount(self):
diff --git a/examples/graphs/3d/widgetgraphgallery/scattergraph.py b/examples/graphs/3d/widgetgraphgallery/scattergraph.py
index 5c8d01e37..00b7fff69 100644
--- a/examples/graphs/3d/widgetgraphgallery/scattergraph.py
+++ b/examples/graphs/3d/widgetgraphgallery/scattergraph.py
@@ -106,9 +106,9 @@ class ScatterGraph(QObject):
itemCountButton.clicked.connect(modifier.toggleItemCount)
rangeButton.clicked.connect(modifier.toggleRanges)
- backgroundCheckBox.stateChanged.connect(modifier.setPlotAreaBackgroundVisible)
- gridCheckBox.stateChanged.connect(modifier.setGridVisible)
- smoothCheckBox.stateChanged.connect(modifier.setSmoothDots)
+ backgroundCheckBox.checkStateChanged.connect(modifier.setPlotAreaBackgroundVisible)
+ gridCheckBox.checkStateChanged.connect(modifier.setGridVisible)
+ smoothCheckBox.checkStateChanged.connect(modifier.setSmoothDots)
modifier.backgroundEnabledChanged.connect(backgroundCheckBox.setChecked)
modifier.gridVisibleChanged.connect(gridCheckBox.setChecked)
diff --git a/examples/graphs/3d/widgetgraphgallery/surfacegraph.py b/examples/graphs/3d/widgetgraphgallery/surfacegraph.py
index d80691b0d..8457251ed 100644
--- a/examples/graphs/3d/widgetgraphgallery/surfacegraph.py
+++ b/examples/graphs/3d/widgetgraphgallery/surfacegraph.py
@@ -233,13 +233,13 @@ class SurfaceGraph(QObject):
# Mode dependent connections
gradientBtoYPB.pressed.connect(modifier.setBlackToYellowGradient)
gradientGtoRPB.pressed.connect(modifier.setGreenToRedGradient)
- checkboxShowOilRigOne.stateChanged.connect(modifier.toggleItemOne)
- checkboxShowOilRigTwo.stateChanged.connect(modifier.toggleItemTwo)
- checkboxShowRefinery.stateChanged.connect(modifier.toggleItemThree)
- checkboxVisualsSeeThrough.stateChanged.connect(modifier.toggleSeeThrough)
- checkboxHighlightOil.stateChanged.connect(modifier.toggleOilHighlight)
- checkboxShowShadows.stateChanged.connect(modifier.toggleShadows)
- enableTexture.stateChanged.connect(modifier.toggleSurfaceTexture)
+ checkboxShowOilRigOne.toggled.connect(modifier.toggleItemOne)
+ checkboxShowOilRigTwo.toggled.connect(modifier.toggleItemTwo)
+ checkboxShowRefinery.toggled.connect(modifier.toggleItemThree)
+ checkboxVisualsSeeThrough.toggled.connect(modifier.toggleSeeThrough)
+ checkboxHighlightOil.toggled.connect(modifier.toggleOilHighlight)
+ checkboxShowShadows.toggled.connect(modifier.toggleShadows)
+ enableTexture.toggled.connect(modifier.toggleSurfaceTexture)
# Connections to disable features depending on mode
sqrtSinModelRB.toggled.connect(colorGroupBox.setVisible)
heightMapModelRB.toggled.connect(showGroupBox.setVisible)
diff --git a/examples/graphs/3d/widgetgraphgallery/surfacegraphmodifier.py b/examples/graphs/3d/widgetgraphgallery/surfacegraphmodifier.py
index c45265082..74bab3491 100644
--- a/examples/graphs/3d/widgetgraphgallery/surfacegraphmodifier.py
+++ b/examples/graphs/3d/widgetgraphgallery/surfacegraphmodifier.py
@@ -276,11 +276,11 @@ class SurfaceGraphModifier(QObject):
def enableHeightMapModel(self, enable):
if enable:
self._heightMapSeriesOne.setDrawMode(QSurface3DSeries.DrawSurface)
- self._heightMapSeriesOne.setFlatShadingEnabled(False)
+ self._heightMapSeriesOne.setShading(QSurface3DSeries.Shading.Flat)
self._heightMapSeriesTwo.setDrawMode(QSurface3DSeries.DrawSurface)
- self._heightMapSeriesTwo.setFlatShadingEnabled(False)
+ self._heightMapSeriesTwo.setShading(QSurface3DSeries.Shading.Flat)
self._heightMapSeriesThree.setDrawMode(QSurface3DSeries.DrawSurface)
- self._heightMapSeriesThree.setFlatShadingEnabled(False)
+ self._heightMapSeriesThree.setShading(QSurface3DSeries.Shading.Flat)
self._graph.axisX().setLabelFormat("%.1f N")
self._graph.axisZ().setLabelFormat("%.1f E")
@@ -580,8 +580,8 @@ class SurfaceGraphModifier(QObject):
@Slot(bool)
def toggleShadows(self, shadows):
- sq = (QtGraphs3D.ShadowQualityMedium
- if shadows else QtGraphs3D.ShadowQualityNone)
+ sq = (QtGraphs3D.ShadowQuality.Medium
+ if shadows else QtGraphs3D.ShadowQuality.None_)
self._graph.setShadowQuality(sq)
@Slot(bool)