aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside6/doc/CMakeLists.txt4
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/add_chart.rst14
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/add_mainwindow.rst8
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/add_tableview.rst33
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize3/datavisualize3.pyproject3
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize3/main_window.py13
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize4/datavisualize4.pyproject3
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize4/main_widget.py8
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize4/main_window.py13
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize4/table_model.py16
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize5/datavisualize5.pyproject3
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize5/main_widget.py41
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize5/main_window.py13
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize5/table_model.py16
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize6/datavisualize6.pyproject3
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_widget.py95
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_window.py14
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/datavisualize6/table_model.py17
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/filter_data.rst7
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/plot_datapoints.rst12
-rw-r--r--sources/pyside6/doc/tutorials/datavisualize/read_data.rst2
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py10
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py62
-rw-r--r--sources/shiboken6_generator/generator/shiboken/cppgenerator.cpp16
-rw-r--r--tools/doc_modules.py2
25 files changed, 262 insertions, 166 deletions
diff --git a/sources/pyside6/doc/CMakeLists.txt b/sources/pyside6/doc/CMakeLists.txt
index e234b7ce8..62a7a430c 100644
--- a/sources/pyside6/doc/CMakeLists.txt
+++ b/sources/pyside6/doc/CMakeLists.txt
@@ -247,6 +247,8 @@ set(CODE_SNIPPET_ROOT "${CMAKE_CURRENT_BINARY_DIR}/${DOC_BASE_DIR}/codesnippets"
if (FULLDOCSBUILD)
shiboken_get_tool_shell_wrapper(shiboken tool_wrapper)
+set(RHI_INCLUDE_DIR ${QT_INCLUDE_DIR}/QtGui/${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}/QtGui)
+
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${DOC_BASE_DIR}/PySide6/QtCore/index.rst"
COMMAND
${tool_wrapper}
@@ -254,7 +256,7 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${DOC_BASE_DIR}/PySide6/Q
--generator-set=qtdoc
${global_header}
--enable-pyside-extensions
- --include-paths="${QT_INCLUDE_DIR}${PATH_SEP}${pyside6_SOURCE_DIR}${PATH_SEP}${TS_ROOT}"
+ --include-paths="${QT_INCLUDE_DIR}${PATH_SEP}${RHI_INCLUDE_DIR}${PATH_SEP}${pyside6_SOURCE_DIR}${PATH_SEP}${TS_ROOT}"
--api-version=${SUPPORTED_QT_VERSION}
--typesystem-paths="${QDOC_TYPESYSTEM_PATH}"
--library-source-dir=${QT_SRC_DIR}
diff --git a/sources/pyside6/doc/tutorials/datavisualize/add_chart.rst b/sources/pyside6/doc/tutorials/datavisualize/add_chart.rst
index acffce40d..87e012021 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/add_chart.rst
+++ b/sources/pyside6/doc/tutorials/datavisualize/add_chart.rst
@@ -5,17 +5,17 @@ Chapter 5 - Add a chart view
=============================
A table is nice to present data, but a chart is even better. For this, you
-need the QtCharts module that provides many types of plots and options to
+need the QtGraphs module that provides many types of plots and options to
graphically represent data.
-The placeholder for a plot is a QChartView, and inside that Widget you can
-place a QChart. As a first step, try including only this without any data to
-plot.
+The relevant class for a plot is the GraphsView QML type, to which axes and
+data series can be added. As a first step, try including then without any data
+to plot.
Make the following highlighted changes to :code:`main_widget.py` from the
-previous chapter to add a QChartView:
+previous chapter to add a chart:
.. literalinclude:: datavisualize5/main_widget.py
:linenos:
- :lines: 3-
- :emphasize-lines: 2-3,6,22-36,47-49
+ :lines: 5-
+ :emphasize-lines: 4,27-39,53
diff --git a/sources/pyside6/doc/tutorials/datavisualize/add_mainwindow.rst b/sources/pyside6/doc/tutorials/datavisualize/add_mainwindow.rst
index ab5468cd6..9073e679a 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/add_mainwindow.rst
+++ b/sources/pyside6/doc/tutorials/datavisualize/add_mainwindow.rst
@@ -4,7 +4,8 @@
Chapter 3 - Create an empty QMainWindow
==========================================
-You can now think of presenting your data in a UI. A QMainWindow provides a
+You can now think of presenting your data in a UI. A
+class:`~PySide6.QtWidgets.QMainWindow` provides a
convenient structure for GUI applications, such as a menu bar and status bar.
The following image shows the layout that QMainWindow offers out-of-the box:
@@ -24,12 +25,13 @@ the resolution you currently have. In the following snippet, you will see how
window size is defined based on available screen width (80%) and height (70%).
.. note:: You can achieve a similar structure using other Qt elements like
- QMenuBar, QWidget, and QStatusBar. Refer the QMainWindow layout for
+ class:`~PySide6.QtWidgets.QMenuBar`, class:`~PySide6.QtWidgets.QWidget`,
+ and class:`~PySide6.QtWidgets.QStatusBar`. Refer the QMainWindow layout for
guidance.
.. literalinclude:: datavisualize3/main_window.py
:language: python
:linenos:
- :lines: 4-
+ :lines: 5-
Try running the script to see what output you get with it.
diff --git a/sources/pyside6/doc/tutorials/datavisualize/add_tableview.rst b/sources/pyside6/doc/tutorials/datavisualize/add_tableview.rst
index 5b7e5e735..b3041349c 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/add_tableview.rst
+++ b/sources/pyside6/doc/tutorials/datavisualize/add_tableview.rst
@@ -8,21 +8,22 @@ Now that you have a QMainWindow, you can include a centralWidget to your
interface. Usually, a QWidget is used to display data in most data-driven
applications. Use a table view to display your data.
-The first step is to add a horizontal layout with just a QTableView. You
-can create a QTableView object and place it inside a QHBoxLayout. Once the
+The first step is to add a horizontal layout with just a
+class:`~PySide6.QtWidgets.QTableView`. You can create a QTableView object
+and place it inside a class:`~PySide6.QtWidgets.QHBoxLayout`. Once the
QWidget is properly built, pass the object to the QMainWindow as its central
widget.
Remember that a QTableView needs a model to display information. In this case,
-you can use a QAbstractTableModel instance.
+you can use a class:`~PySide6.QtCore.QAbstractTableModel` instance.
.. note:: You could also use the default item model that comes with a
- QTableWidget instead. QTableWidget is a convenience class that reduces
- your codebase considerably as you don't need to implement a data model.
- However, it's less flexible than a QTableView, as QTableWidget cannot be
- used with just any data. For more insight about Qt's model-view framework,
- refer to the
- `Model View Programming <https://doc.qt.io/qt-5/model-view-programming.html>`
+ class:`~PySide6.QtWidgets.QTableWidget` instead. QTableWidget is a
+ convenience class that reduces your codebase considerably as you don't need
+ to implement a data model. However, it's less flexible than a QTableView,
+ as QTableWidget cannot be used with just any data. For more insight about
+ Qt's model-view framework, refer to the
+ `Model View Programming <https://doc.qt.io/qt-6/model-view-programming.html>`
documentation.
Implementing the model for your QTableView, allows you to:
@@ -42,7 +43,7 @@ Here is a script that implements the CustomTableModel:
.. literalinclude:: datavisualize4/table_model.py
:language: python
:linenos:
- :lines: 3-
+ :lines: 5-
Now, create a QWidget that has a QTableView, and connect it to your
CustomTableModel.
@@ -50,8 +51,8 @@ CustomTableModel.
.. literalinclude:: datavisualize4/main_widget.py
:language: python
:linenos:
- :emphasize-lines: 12-17
- :lines: 3-
+ :emphasize-lines: 12-12
+ :lines: 5-
You also need minor changes to the :code:`main_window.py` and
:code:`main.py` from chapter 3 to include the Widget inside the
@@ -62,11 +63,11 @@ In the following snippets you'll see those changes highlighted:
.. literalinclude:: datavisualize4/main_window.py
:language: python
:linenos:
- :lines: 3-
- :emphasize-lines: 8,11
+ :lines: 5-
+ :emphasize-lines: 9
.. literalinclude:: datavisualize4/main.py
:language: python
:linenos:
- :lines: 3-
- :emphasize-lines: 46-47
+ :lines: 5-
+ :emphasize-lines: 45-46
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize3/datavisualize3.pyproject b/sources/pyside6/doc/tutorials/datavisualize/datavisualize3/datavisualize3.pyproject
new file mode 100644
index 000000000..1bd31f959
--- /dev/null
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize3/datavisualize3.pyproject
@@ -0,0 +1,3 @@
+{
+ "files": ["main.py", "main_window.py"]
+}
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize3/main_window.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize3/main_window.py
index 6ee8fa61b..79a4afd36 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize3/main_window.py
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize3/main_window.py
@@ -2,25 +2,22 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
from __future__ import annotations
-from PySide6.QtGui import QAction, QKeySequence
+from PySide6.QtGui import QIcon, QKeySequence
from PySide6.QtWidgets import QMainWindow
class MainWindow(QMainWindow):
def __init__(self):
- QMainWindow.__init__(self)
+ super().__init__()
self.setWindowTitle("Eartquakes information")
# Menu
self.menu = self.menuBar()
- self.file_menu = self.menu.addMenu("File")
+ file_menu = self.menu.addMenu("File")
# Exit QAction
- exit_action = QAction("Exit", self)
- exit_action.setShortcut(QKeySequence.Quit)
- exit_action.triggered.connect(self.close)
-
- self.file_menu.addAction(exit_action)
+ file_menu.addAction(QIcon.fromTheme(QIcon.ThemeIcon.ApplicationExit),
+ "Exit", QKeySequence.StandardKey.Quit, self.close)
# Status Bar
self.status = self.statusBar()
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/datavisualize4.pyproject b/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/datavisualize4.pyproject
new file mode 100644
index 000000000..f54969728
--- /dev/null
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/datavisualize4.pyproject
@@ -0,0 +1,3 @@
+{
+ "files": ["main.py", "main_widget.py", "main_window.py", "table_model.py"]
+}
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/main_widget.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/main_widget.py
index 85e24833f..5d8e6ade3 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/main_widget.py
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/main_widget.py
@@ -10,7 +10,7 @@ from table_model import CustomTableModel
class Widget(QWidget):
def __init__(self, data):
- QWidget.__init__(self)
+ super().__init__()
# Getting the Model
self.model = CustomTableModel(data)
@@ -22,13 +22,13 @@ class Widget(QWidget):
# QTableView Headers
self.horizontal_header = self.table_view.horizontalHeader()
self.vertical_header = self.table_view.verticalHeader()
- self.horizontal_header.setSectionResizeMode(QHeaderView.ResizeToContents)
- self.vertical_header.setSectionResizeMode(QHeaderView.ResizeToContents)
+ self.horizontal_header.setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
+ self.vertical_header.setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
self.horizontal_header.setStretchLastSection(True)
# QWidget Layout
self.main_layout = QHBoxLayout()
- size = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
+ size = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred)
# Left layout
size.setHorizontalStretch(1)
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/main_window.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/main_window.py
index ded7fdf5c..600af6503 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/main_window.py
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/main_window.py
@@ -2,25 +2,22 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
from __future__ import annotations
-from PySide6.QtGui import QAction, QKeySequence
+from PySide6.QtGui import QIcon, QKeySequence
from PySide6.QtWidgets import QMainWindow
class MainWindow(QMainWindow):
def __init__(self, widget):
- QMainWindow.__init__(self)
+ super().__init__()
self.setWindowTitle("Eartquakes information")
self.setCentralWidget(widget)
# Menu
self.menu = self.menuBar()
- self.file_menu = self.menu.addMenu("File")
+ file_menu = self.menu.addMenu("File")
# Exit QAction
- exit_action = QAction("Exit", self)
- exit_action.setShortcut(QKeySequence.Quit)
- exit_action.triggered.connect(self.close)
-
- self.file_menu.addAction(exit_action)
+ file_menu.addAction(QIcon.fromTheme(QIcon.ThemeIcon.ApplicationExit),
+ "Exit", QKeySequence.StandardKey.Quit, self.close)
# Status Bar
self.status = self.statusBar()
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/table_model.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/table_model.py
index cc2ac12ab..9a2871c22 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/table_model.py
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize4/table_model.py
@@ -25,27 +25,27 @@ class CustomTableModel(QAbstractTableModel):
return self.column_count
def headerData(self, section, orientation, role):
- if role != Qt.DisplayRole:
+ if role != Qt.ItemDataRole.DisplayRole:
return None
- if orientation == Qt.Horizontal:
+ if orientation == Qt.Orientation.Horizontal:
return ("Date", "Magnitude")[section]
else:
return f"{section}"
- def data(self, index, role=Qt.DisplayRole):
+ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
column = index.column()
row = index.row()
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if column == 0:
date = self.input_dates[row].toPython()
return str(date)[:-3]
elif column == 1:
magnitude = self.input_magnitudes[row]
return f"{magnitude:.2f}"
- elif role == Qt.BackgroundRole:
- return QColor(Qt.white)
- elif role == Qt.TextAlignmentRole:
- return Qt.AlignRight
+ elif role == Qt.ItemDataRole.BackgroundRole:
+ return QColor(Qt.GlobalColor.white)
+ elif role == Qt.ItemDataRole.TextAlignmentRole:
+ return Qt.AlignmentFlag.AlignRight
return None
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/datavisualize5.pyproject b/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/datavisualize5.pyproject
new file mode 100644
index 000000000..f54969728
--- /dev/null
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/datavisualize5.pyproject
@@ -0,0 +1,3 @@
+{
+ "files": ["main.py", "main_widget.py", "main_window.py", "table_model.py"]
+}
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/main_widget.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/main_widget.py
index 77ea4e776..fca09b059 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/main_widget.py
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/main_widget.py
@@ -2,17 +2,17 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
from __future__ import annotations
-from PySide6.QtGui import QPainter
from PySide6.QtWidgets import (QWidget, QHeaderView, QHBoxLayout, QTableView,
QSizePolicy)
-from PySide6.QtCharts import QChart, QChartView
+from PySide6.QtQuickWidgets import QQuickWidget
+from PySide6.QtGraphs import QLineSeries, QDateTimeAxis, QValueAxis, QGraphsTheme
from table_model import CustomTableModel
class Widget(QWidget):
def __init__(self, data):
- QWidget.__init__(self)
+ super().__init__()
# Getting the Model
self.model = CustomTableModel(data)
@@ -24,21 +24,27 @@ class Widget(QWidget):
# QTableView Headers
self.horizontal_header = self.table_view.horizontalHeader()
self.vertical_header = self.table_view.verticalHeader()
- self.horizontal_header.setSectionResizeMode(QHeaderView.ResizeToContents)
- self.vertical_header.setSectionResizeMode(QHeaderView.ResizeToContents)
+ self.horizontal_header.setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
+ self.vertical_header.setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
self.horizontal_header.setStretchLastSection(True)
- # Creating QChart
- self.chart = QChart()
- self.chart.setAnimationOptions(QChart.AllAnimations)
-
- # Creating QChartView
- self.chart_view = QChartView(self.chart)
- self.chart_view.setRenderHint(QPainter.Antialiasing)
+ # Create QGraphView via QML
+ self.series = QLineSeries()
+ self.axis_x = QDateTimeAxis()
+ self.axis_y = QValueAxis()
+ self.quick_widget = QQuickWidget(self)
+ self.quick_widget.setResizeMode(QQuickWidget.ResizeMode.SizeRootObjectToView)
+ self.theme = QGraphsTheme()
+ initial_properties = {"theme": self.theme,
+ "axisX": self.axis_x,
+ "axisY": self.axis_y,
+ "seriesList": self.series}
+ self.quick_widget.setInitialProperties(initial_properties)
+ self.quick_widget.loadFromModule("QtGraphs", "GraphsView")
# QWidget Layout
- self.main_layout = QHBoxLayout()
- size = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
+ self.main_layout = QHBoxLayout(self)
+ size = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred)
# Left layout
size.setHorizontalStretch(1)
@@ -47,8 +53,5 @@ class Widget(QWidget):
# Right Layout
size.setHorizontalStretch(4)
- self.chart_view.setSizePolicy(size)
- self.main_layout.addWidget(self.chart_view)
-
- # Set the layout to the QWidget
- self.setLayout(self.main_layout)
+ self.quick_widget.setSizePolicy(size)
+ self.main_layout.addWidget(self.quick_widget)
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/main_window.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/main_window.py
index ded7fdf5c..600af6503 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/main_window.py
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/main_window.py
@@ -2,25 +2,22 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
from __future__ import annotations
-from PySide6.QtGui import QAction, QKeySequence
+from PySide6.QtGui import QIcon, QKeySequence
from PySide6.QtWidgets import QMainWindow
class MainWindow(QMainWindow):
def __init__(self, widget):
- QMainWindow.__init__(self)
+ super().__init__()
self.setWindowTitle("Eartquakes information")
self.setCentralWidget(widget)
# Menu
self.menu = self.menuBar()
- self.file_menu = self.menu.addMenu("File")
+ file_menu = self.menu.addMenu("File")
# Exit QAction
- exit_action = QAction("Exit", self)
- exit_action.setShortcut(QKeySequence.Quit)
- exit_action.triggered.connect(self.close)
-
- self.file_menu.addAction(exit_action)
+ file_menu.addAction(QIcon.fromTheme(QIcon.ThemeIcon.ApplicationExit),
+ "Exit", QKeySequence.StandardKey.Quit, self.close)
# Status Bar
self.status = self.statusBar()
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/table_model.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/table_model.py
index cc2ac12ab..9a2871c22 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/table_model.py
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize5/table_model.py
@@ -25,27 +25,27 @@ class CustomTableModel(QAbstractTableModel):
return self.column_count
def headerData(self, section, orientation, role):
- if role != Qt.DisplayRole:
+ if role != Qt.ItemDataRole.DisplayRole:
return None
- if orientation == Qt.Horizontal:
+ if orientation == Qt.Orientation.Horizontal:
return ("Date", "Magnitude")[section]
else:
return f"{section}"
- def data(self, index, role=Qt.DisplayRole):
+ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
column = index.column()
row = index.row()
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if column == 0:
date = self.input_dates[row].toPython()
return str(date)[:-3]
elif column == 1:
magnitude = self.input_magnitudes[row]
return f"{magnitude:.2f}"
- elif role == Qt.BackgroundRole:
- return QColor(Qt.white)
- elif role == Qt.TextAlignmentRole:
- return Qt.AlignRight
+ elif role == Qt.ItemDataRole.BackgroundRole:
+ return QColor(Qt.GlobalColor.white)
+ elif role == Qt.ItemDataRole.TextAlignmentRole:
+ return Qt.AlignmentFlag.AlignRight
return None
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/datavisualize6.pyproject b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/datavisualize6.pyproject
new file mode 100644
index 000000000..f54969728
--- /dev/null
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/datavisualize6.pyproject
@@ -0,0 +1,3 @@
+{
+ "files": ["main.py", "main_widget.py", "main_window.py", "table_model.py"]
+}
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_widget.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_widget.py
index f987689ea..336afacd8 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_widget.py
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_widget.py
@@ -2,18 +2,20 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
from __future__ import annotations
-from PySide6.QtCore import QDateTime, Qt
-from PySide6.QtGui import QPainter
+from math import floor, ceil
+
+from PySide6.QtCore import QDateTime, QTime, QTimeZone
from PySide6.QtWidgets import (QWidget, QHeaderView, QHBoxLayout, QTableView,
QSizePolicy)
-from PySide6.QtCharts import QChart, QChartView, QLineSeries, QDateTimeAxis, QValueAxis
+from PySide6.QtQuickWidgets import QQuickWidget
+from PySide6.QtGraphs import QLineSeries, QDateTimeAxis, QValueAxis, QGraphsTheme
from table_model import CustomTableModel
class Widget(QWidget):
def __init__(self, data):
- QWidget.__init__(self)
+ super().__init__()
# Getting the Model
self.model = CustomTableModel(data)
@@ -23,25 +25,29 @@ class Widget(QWidget):
self.table_view.setModel(self.model)
# QTableView Headers
- resize = QHeaderView.ResizeToContents
+ resize = QHeaderView.ResizeMode.ResizeToContents
self.horizontal_header = self.table_view.horizontalHeader()
self.vertical_header = self.table_view.verticalHeader()
self.horizontal_header.setSectionResizeMode(resize)
self.vertical_header.setSectionResizeMode(resize)
self.horizontal_header.setStretchLastSection(True)
- # Creating QChart
- self.chart = QChart()
- self.chart.setAnimationOptions(QChart.AllAnimations)
- self.add_series("Magnitude (Column 1)", [0, 1])
-
- # Creating QChartView
- self.chart_view = QChartView(self.chart)
- self.chart_view.setRenderHint(QPainter.Antialiasing)
+ # Create QGraphView via QML
+ self.populate_series()
+ self.quick_widget = QQuickWidget(self)
+ self.quick_widget.setResizeMode(QQuickWidget.ResizeMode.SizeRootObjectToView)
+ self.theme = QGraphsTheme()
+ self.theme.setTheme(QGraphsTheme.Theme.BlueSeries)
+ initial_properties = {"theme": self.theme,
+ "axisX": self.axis_x,
+ "axisY": self.axis_y,
+ "seriesList": self.series}
+ self.quick_widget.setInitialProperties(initial_properties)
+ self.quick_widget.loadFromModule("QtGraphs", "GraphsView")
# QWidget Layout
- self.main_layout = QHBoxLayout()
- size = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
+ self.main_layout = QHBoxLayout(self)
+ size = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred)
# Left layout
size.setHorizontalStretch(1)
@@ -50,46 +56,51 @@ class Widget(QWidget):
# Right Layout
size.setHorizontalStretch(4)
- self.chart_view.setSizePolicy(size)
- self.main_layout.addWidget(self.chart_view)
+ self.quick_widget.setSizePolicy(size)
+ self.main_layout.addWidget(self.quick_widget)
- # Set the layout to the QWidget
- self.setLayout(self.main_layout)
+ def populate_series(self):
+ def seconds(qtime: QTime):
+ return qtime.minute() * 60 + qtime.second()
- def add_series(self, name, columns):
- # Create QLineSeries
self.series = QLineSeries()
- self.series.setName(name)
+ self.series.setName("Magnitude (Column 1)")
# Filling QLineSeries
+ time_min = QDateTime(2100, 1, 1, 0, 0, 0)
+ time_max = QDateTime(1970, 1, 1, 0, 0, 0)
+ time_zone = QTimeZone(QTimeZone.Initialization.UTC)
+ y_min = 1e37
+ y_max = -1e37
+ date_fmt = "yyyy-MM-dd HH:mm:ss.zzz"
for i in range(self.model.rowCount()):
- # Getting the data
t = self.model.index(i, 0).data()
- date_fmt = "yyyy-MM-dd HH:mm:ss.zzz"
-
- x = QDateTime().fromString(t, date_fmt).toSecsSinceEpoch()
+ time = QDateTime.fromString(t, date_fmt)
+ time.setTimeZone(time_zone)
y = float(self.model.index(i, 1).data())
-
- if x > 0 and y > 0:
- self.series.append(x, y)
-
- self.chart.addSeries(self.series)
+ if time.isValid() and y > 0:
+ if time > time_max:
+ time_max = time
+ if time < time_min:
+ time_min = time
+ if y > y_max:
+ y_max = y
+ if y < y_min:
+ y_min = y
+ self.series.append(time.toMSecsSinceEpoch(), y)
# Setting X-axis
self.axis_x = QDateTimeAxis()
- self.axis_x.setTickCount(10)
- self.axis_x.setFormat("dd.MM (h:mm)")
+ self.axis_x.setLabelFormat("dd.MM (h:mm)")
self.axis_x.setTitleText("Date")
- self.chart.addAxis(self.axis_x, Qt.AlignBottom)
- self.series.attachAxis(self.axis_x)
+ self.axis_x.setMin(time_min.addSecs(-seconds(time_min.time())))
+ self.axis_x.setMax(time_max.addSecs(3600 - seconds(time_max.time())))
+ self.series.setAxisX(self.axis_x)
+
# Setting Y-axis
self.axis_y = QValueAxis()
- self.axis_y.setTickCount(10)
self.axis_y.setLabelFormat("%.2f")
self.axis_y.setTitleText("Magnitude")
- self.chart.addAxis(self.axis_y, Qt.AlignLeft)
- self.series.attachAxis(self.axis_y)
-
- # Getting the color from the QChart to use it on the QTableView
- color_name = self.series.pen().color().name()
- self.model.color = f"{color_name}"
+ self.axis_y.setMin(floor(y_min))
+ self.axis_y.setMax(ceil(y_max))
+ self.series.setAxisY(self.axis_y)
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_window.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_window.py
index f37268df8..6a9eaea8e 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_window.py
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/main_window.py
@@ -2,26 +2,22 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
from __future__ import annotations
-from PySide6.QtGui import QAction, QKeySequence
+from PySide6.QtGui import QIcon, QKeySequence
from PySide6.QtWidgets import QMainWindow
class MainWindow(QMainWindow):
def __init__(self, widget):
- QMainWindow.__init__(self)
+ super().__init__()
self.setWindowTitle("Eartquakes information")
# Menu
self.menu = self.menuBar()
- self.file_menu = self.menu.addMenu("File")
+ file_menu = self.menu.addMenu("File")
# Exit QAction
- exit_action = QAction("Exit", self)
- exit_action.setShortcut(QKeySequence.Quit)
- exit_action.triggered.connect(self.close)
-
- self.file_menu.addAction(exit_action)
-
+ file_menu.addAction(QIcon.fromTheme(QIcon.ThemeIcon.ApplicationExit),
+ "Exit", QKeySequence.StandardKey.Quit, self.close)
# Status Bar
self.status = self.statusBar()
self.status.showMessage("Data loaded and plotted")
diff --git a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/table_model.py b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/table_model.py
index 3201e5887..9a2871c22 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/table_model.py
+++ b/sources/pyside6/doc/tutorials/datavisualize/datavisualize6/table_model.py
@@ -9,7 +9,6 @@ from PySide6.QtGui import QColor
class CustomTableModel(QAbstractTableModel):
def __init__(self, data=None):
QAbstractTableModel.__init__(self)
- self.color = None
self.load_data(data)
def load_data(self, data):
@@ -26,27 +25,27 @@ class CustomTableModel(QAbstractTableModel):
return self.column_count
def headerData(self, section, orientation, role):
- if role != Qt.DisplayRole:
+ if role != Qt.ItemDataRole.DisplayRole:
return None
- if orientation == Qt.Horizontal:
+ if orientation == Qt.Orientation.Horizontal:
return ("Date", "Magnitude")[section]
else:
return f"{section}"
- def data(self, index, role=Qt.DisplayRole):
+ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
column = index.column()
row = index.row()
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if column == 0:
date = self.input_dates[row].toPython()
return str(date)[:-3]
elif column == 1:
magnitude = self.input_magnitudes[row]
return f"{magnitude:.2f}"
- elif role == Qt.BackgroundRole:
- return (QColor(Qt.white), QColor(self.color))[column]
- elif role == Qt.TextAlignmentRole:
- return Qt.AlignRight
+ elif role == Qt.ItemDataRole.BackgroundRole:
+ return QColor(Qt.GlobalColor.white)
+ elif role == Qt.ItemDataRole.TextAlignmentRole:
+ return Qt.AlignmentFlag.AlignRight
return None
diff --git a/sources/pyside6/doc/tutorials/datavisualize/filter_data.rst b/sources/pyside6/doc/tutorials/datavisualize/filter_data.rst
index bef134e5b..4edde69c1 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/filter_data.rst
+++ b/sources/pyside6/doc/tutorials/datavisualize/filter_data.rst
@@ -17,7 +17,8 @@ be done by filtering the data that follows the condition, "magnitude > 0", to
avoid faulty data or unexpected behavior.
The Date column provides data in UTC format (for example,
-2018-12-11T21:14:44.682Z), so you could easily map it to a QDateTime object
+2018-12-11T21:14:44.682Z), so you could easily map it to a
+class:`~PySide6.QtCore.QDateTime` object
defining the structure of the string. Additionally, you can adapt the time
based on the timezone you are in, using QTimeZone.
@@ -26,7 +27,7 @@ The following script filters and formats the CSV data as described earlier:
.. literalinclude:: datavisualize2/main.py
:language: python
:linenos:
- :lines: 3-
+ :lines: 5-
-Now that you have a tuple of QDateTime and float data, try improving the
+Now that you have a tuple of ``QDateTime`` and float data, try improving the
output further. That's what you'll learn in the following chapters.
diff --git a/sources/pyside6/doc/tutorials/datavisualize/plot_datapoints.rst b/sources/pyside6/doc/tutorials/datavisualize/plot_datapoints.rst
index e4374e861..47d12a7c4 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/plot_datapoints.rst
+++ b/sources/pyside6/doc/tutorials/datavisualize/plot_datapoints.rst
@@ -1,23 +1,23 @@
.. _tutorial_plot_datapoints:
-Chapter 6 - Plot the data in the ChartView
+Chapter 6 - Plot the data in the GraphsView
===========================================
-The last step of this tutorial is to plot the CSV data inside our QChart. For
-this, you need to go over our data and include the data on a QLineSeries.
+The last step of this tutorial is to plot the CSV data inside our GraphsView.
+For this, you need to go over our data and include the data on a QLineSeries.
After adding the data to the series, you can modify the axis to properly
display the QDateTime on the X-axis, and the magnitude values on the Y-axis.
Here is the updated :code:`main_widget.py` that includes an additional
-function to plot data using a QLineSeries:
+function to plot data using a :class:`~PySide6.QtGraphs.QLineSeries`:
.. literalinclude:: datavisualize6/main_widget.py
:language: python
:linenos:
- :lines: 3-
- :emphasize-lines: 33,56-91
+ :lines: 5-
+ :emphasize-lines: 31-42, 68-102
Now, run the application to visualize the earthquake magnitudes
data at different times.
diff --git a/sources/pyside6/doc/tutorials/datavisualize/read_data.rst b/sources/pyside6/doc/tutorials/datavisualize/read_data.rst
index 8be0e1c2f..d083a05ee 100644
--- a/sources/pyside6/doc/tutorials/datavisualize/read_data.rst
+++ b/sources/pyside6/doc/tutorials/datavisualize/read_data.rst
@@ -21,7 +21,7 @@ The following python script, :code:`main.py`, demonstrates how to do it:
.. literalinclude:: datavisualize1/main.py
:language: python
:linenos:
- :lines: 3-
+ :lines: 5-
The Python script uses the :code:`argparse` module to accept and parse input
from the command line. It then uses the input, which in this case is the filename,
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py
index 6f86df8c8..b31b161a3 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py
@@ -53,6 +53,12 @@ def is_inconsistent_overload(signatures):
return count != 0 and count != len(signatures)
+def is_relevant_type(thing):
+ t = str(type(thing))
+ return (("PySide" in t or "getset_descriptor" in t)
+ and "QMetaObject" not in t)
+
+
class ExactEnumerator:
"""
ExactEnumerator enumerates all signatures in a module as they are.
@@ -178,7 +184,9 @@ class ExactEnumerator:
# Support attributes that have PySide types as values,
# but we skip the 'staticMetaObject' that needs
# to be defined at a QObject level.
- elif "PySide" in str(type(thing)) and "QMetaObject" not in str(type(thing)):
+ # PYSIDE-3034: added public variables, extracted helper function to
+ # avoid repetitive calls of str(type(thing))
+ elif is_relevant_type(thing):
if class_name not in attributes:
attributes[class_name] = {}
attributes[class_name][thing_name] = thing
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py
index cdb4d9575..a84eb38dd 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py
@@ -32,6 +32,38 @@ from shibokensupport.signature.lib.tool import build_brace_pattern
indent = " " * 4
+TYPE_MAP = {
+ # Qt integer types
+ "qint64": "int",
+ "qint32": "int",
+ "qint16": "int",
+ "qsizetype": "int",
+ "quint32": "int",
+ "quint64": "int",
+ "size_t": "int",
+ "uint": "int",
+ "ushort": "int",
+ "ulong": "int",
+ "unsigned char": "int",
+ "unsigned int": "int",
+
+ # Qt floating types
+ "qreal": "float",
+
+ # Qt string-like
+ "QString": "str",
+ "QStringList": "typing.List[str]",
+ "QChar": "str",
+
+ # Qt containers (minimal)
+ "QList": "typing.List",
+ "QVariant": "typing.Any",
+
+ # C strings
+ "char*": "str",
+ "const char*": "str",
+}
+
class Writer:
def __init__(self, outfile, *args):
@@ -86,6 +118,29 @@ class Formatter(Writer):
inspect.formatannotation = cls.backup
return stringized
+ @classmethod
+ def normalize_type(cls, type_repr: str) -> str:
+ if not type_repr:
+ return "typing.Any"
+ if type_repr in {"void", "void*"}:
+ return "typing.Any"
+ if any(x in type_repr for x in ("QRhi", ".ComponentType", ".Semantic")):
+ return "int"
+ if ( " " in type_repr and
+ not any(x in type_repr for x in ("*", "::", "<", ">", "[", "]"))):
+ return "typing.Any"
+ if type_repr.startswith("QList["):
+ inner = type_repr[len("QList["):-1]
+ inner = cls.normalize_type(inner)
+ return f"typing.List[{inner}]"
+ if type_repr.startswith("QMap[") or type_repr.startswith("QHash["):
+ inner = type_repr[type_repr.find("[") + 1:-1]
+ key, value = map(str.strip, inner.split(",", 1))
+ key = cls.normalize_type(key)
+ value = cls.normalize_type(value)
+ return f"typing.Dict[{key}, {value}]"
+ return TYPE_MAP.get(type_repr, type_repr)
+
# Adding a pattern to substitute "Union[T, NoneType]" by "Optional[T]"
# I tried hard to replace typing.Optional by a simple override, but
# this became _way_ too much.
@@ -221,7 +276,12 @@ class Formatter(Writer):
spaces = indent * self.level
# PYSIDE-2903: Use a fully qualified name in the type comment.
full_name = f"{type(attr_value).__module__}.{type(attr_value).__qualname__}"
- self.print(f"{spaces}{attr_name:25} = ... # type: {full_name}")
+ if full_name == "builtins.getset_descriptor":
+ # PYSIDE-3034: Public variable types added to __doc__
+ type_repr = self.normalize_type(attr_value.__doc__)
+ else:
+ type_repr = full_name
+ self.print(f"{spaces}{attr_name:25} = ... # type: {type_repr}")
yield
@contextmanager
diff --git a/sources/shiboken6_generator/generator/shiboken/cppgenerator.cpp b/sources/shiboken6_generator/generator/shiboken/cppgenerator.cpp
index 4854ebf79..e87a53bb8 100644
--- a/sources/shiboken6_generator/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6_generator/generator/shiboken/cppgenerator.cpp
@@ -480,10 +480,17 @@ static QString BuildEnumFlagInfo(const AbstractMetaEnum &cppEnum)
}
static void writePyGetSetDefEntry(TextStream &s, const QString &name,
- const QString &getFunc, const QString &setFunc)
+ const QString &getFunc, const QString &setFunc, const QString &doc={})
{
- s << "{const_cast<char *>(\"" << mangleName(name) << "\"), " << getFunc << ", "
- << (setFunc.isEmpty() ? NULL_PTR : setFunc) << ", nullptr, nullptr},\n";
+ s << "{\"" << mangleName(name) << "\", " << getFunc << ", "
+ << (setFunc.isEmpty() ? NULL_PTR : setFunc) << ", ";
+
+ if (doc.isEmpty())
+ s << "nullptr";
+ else
+ s << "\"" << doc << "\"";
+
+ s << ", nullptr},\n";
}
static bool generateRichComparison(const GeneratorContext &c)
@@ -922,8 +929,9 @@ void CppGenerator::generateClass(TextStream &s,
const QString setter = canGenerateSetter
? cpythonSetterFunctionName(metaField) : QString();
const auto names = metaField.definitionNames();
+ const QString doc = metaField.type().pythonSignature();
for (const auto &name : names)
- writePyGetSetDefEntry(s, name, getter, setter);
+ writePyGetSetDefEntry(s, name, getter, setter, doc);
}
}
diff --git a/tools/doc_modules.py b/tools/doc_modules.py
index a26811a90..243dd28fd 100644
--- a/tools/doc_modules.py
+++ b/tools/doc_modules.py
@@ -118,6 +118,8 @@ def _write_global_header(modules, file):
"""Helper to write the global header for shiboken."""
for module in modules:
print(f"#include <{module}/{module}>", file=file)
+ if module == "QtGui":
+ print("#include <rhi/qrhi.h>", file=file)
def write_global_header(modules, filename):