diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-10-21 19:13:32 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-10-21 19:13:32 +0200 |
commit | 55fd16d92a36558335e7d7cd7cdb57ead43d55db (patch) | |
tree | 2573c4fabdb80535972a3c91a262f2e3fa80cf80 /sources | |
parent | e8d90a9e62898d3b746772d9ae8542b87efcecf8 (diff) | |
parent | 85bb24c39df53ea61f59351a60f4284c32cb50ff (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I8831b840fa7816b8919ecbaab17b41822a0a6012
Diffstat (limited to 'sources')
19 files changed, 309 insertions, 247 deletions
diff --git a/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml b/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml index a221ef41a..92c3f2b07 100644 --- a/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml +++ b/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml @@ -198,7 +198,7 @@ </object-type> <object-type name="QShaderData"/> <object-type name="QShaderProgram"> - <enum-type name="Format" since="6.0"/> + <enum-type name="Format"/> <enum-type name="ShaderType"/> <enum-type name="Status"/> </object-type> diff --git a/sources/pyside2/PySide2/QtCharts/typesystem_charts.xml b/sources/pyside2/PySide2/QtCharts/typesystem_charts.xml index 967118cd9..8ab734704 100644 --- a/sources/pyside2/PySide2/QtCharts/typesystem_charts.xml +++ b/sources/pyside2/PySide2/QtCharts/typesystem_charts.xml @@ -257,7 +257,9 @@ </object-type> <object-type name="QSplineSeries" since="5.7"/> <object-type name="QStackedBarSeries" since="5.7"/> - <object-type name="QValueAxis" since="5.7"/> + <object-type name="QValueAxis" since="5.7"> + <enum-type name="TickType"/> + </object-type> <object-type name="QVBarModelMapper" since="5.7"/> <object-type name="QVBoxPlotModelMapper" since="5.7"/> <object-type name="QVCandlestickModelMapper" since="5.7"/> diff --git a/sources/pyside2/PySide2/QtRemoteObjects/CMakeLists.txt b/sources/pyside2/PySide2/QtRemoteObjects/CMakeLists.txt index d8fd6674f..98553b6a0 100644 --- a/sources/pyside2/PySide2/QtRemoteObjects/CMakeLists.txt +++ b/sources/pyside2/PySide2/QtRemoteObjects/CMakeLists.txt @@ -14,6 +14,7 @@ ${QtRemoteObjects_GEN_DIR}/qremoteobjectregistryhost_wrapper.cpp ${QtRemoteObjects_GEN_DIR}/qremoteobjectreplica_wrapper.cpp # ${QtRemoteObjects_GEN_DIR}/qtremoteobjects_wrapper.cpp ${QtRemoteObjects_GEN_DIR}/qremoteobjectsettingsstore_wrapper.cpp +${QtRemoteObjects_GEN_DIR}/qremoteobjectsourcelocationinfo_wrapper.cpp # module is always needed ${QtRemoteObjects_GEN_DIR}/qtremoteobjects_module_wrapper.cpp diff --git a/sources/pyside2/PySide2/QtRemoteObjects/typesystem_remoteobjects.xml b/sources/pyside2/PySide2/QtRemoteObjects/typesystem_remoteobjects.xml index d8d54b4fb..b4f7ed13b 100644 --- a/sources/pyside2/PySide2/QtRemoteObjects/typesystem_remoteobjects.xml +++ b/sources/pyside2/PySide2/QtRemoteObjects/typesystem_remoteobjects.xml @@ -71,4 +71,5 @@ <!-- protected: <enum-type name="ConstructorType"/> --> </object-type> <object-type name="QRemoteObjectSettingsStore"/> + <value-type name="QRemoteObjectSourceLocationInfo"/> </typesystem> diff --git a/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml b/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml index b18d4359a..2519101d7 100644 --- a/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml +++ b/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml @@ -64,6 +64,7 @@ <value-type name="QWebEngineHistoryItem"/> <object-type name="QWebEnginePage"> + <enum-type name="LifecycleState"/> <enum-type name="WebAction"/> <enum-type name="FindFlag" flags="FindFlags"/> <enum-type name="WebWindowType"/> diff --git a/sources/pyside2/doc/gettingstarted-linux.rst b/sources/pyside2/doc/gettingstarted-linux.rst index 6192ab190..0474d457f 100644 --- a/sources/pyside2/doc/gettingstarted-linux.rst +++ b/sources/pyside2/doc/gettingstarted-linux.rst @@ -4,20 +4,17 @@ Getting Started on Linux Requirements ------------ - * Qt package from `here`_ or a custom build of Qt (preferably - Qt 5.12 or greater) + * Qt package from `here`_ or a custom build of Qt 5.12+ (preferably 5.15) * A Python interpreter (version Python 3.5+ or Python 2.7). You can either use the one provided by your OS, or get it from the `official website`_. * GCC * `CMake`_ version 3.1 or greater * Git version 2 or greater - * `libclang`_ from your system or the prebuilt version from the - ``Qt Downloads`` page is recommended. - * ``virtualenv`` is strongly recommended, but optional. + * `libclang`_ from your system or the prebuilt version from the ``Qt Downloads`` page is + recommended. libclang10 is required for PySide 5.15. * ``sphinx`` package for the documentation (optional). - * Depending on your linux distribution, the following dependencies might - also be required: + * Depending on your linux distribution, the following dependencies might also be required: * ``libgl-dev``, * ``python-dev``, @@ -36,13 +33,12 @@ Building from source Creating a virtual environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -``virtualenv`` allows you to create a local, user-writeable copy of a python environment into +The ``venv`` module allows you to create a local, user-writeable copy of a python environment into which arbitrary modules can be installed and which can be removed after use:: - virtualenv testenv + python -m venv testenv source testenv/bin/activate - pip install sphinx # optional: documentation - pip install numpy PyOpenGL # optional: for examples + pip install -r requirements.txt # General dependencies, documentation, and examples. will create and use a new virtual environment, which is indicated by the command prompt changing. @@ -51,12 +47,12 @@ Setting up CLANG If you don't have libclang already in your system, you can download from the Qt servers:: - wget https://download.qt.io/development_releases/prebuilt/libclang/libclang-release_60-linux-Rhel7.2-gcc5.3-x86_64-clazy.7z + wget https://download.qt.io/development_releases/prebuilt/libclang/libclang-release_100-based-linux-Rhel7.6-gcc5.3-x86_64.7z Extract the files, and leave it on any desired path, and then set these two required environment variables:: - 7z x libclang-release_60-linux-Rhel7.2-gcc5.3-x86_64-clazy.7z + 7z x libclang-release_100-based-linux-Rhel7.6-gcc5.3-x86_64.7z export CLANG_INSTALL_DIR=$PWD/libclang Getting PySide2 @@ -66,12 +62,12 @@ Cloning the official repository can be done by:: git clone --recursive https://code.qt.io/pyside/pyside-setup -Checking out the version that we want to build, e.g. 5.14:: +Checking out the version that we want to build, e.g. 5.15:: - cd pyside-setup && git checkout 5.14 + cd pyside-setup && git checkout 5.15 .. note:: Keep in mind you need to use the same version as your Qt installation. - Additionally, ``git checkout -b 5.14 --track origin/5.14`` could be a better option + Additionally, ``git checkout -b 5.15 --track origin/5.14`` could be a better option in case you want to work on it. Building PySide2 @@ -82,14 +78,14 @@ e.g. ``/opt/Qt/5.14.0/gcc_64/bin/qmake``. Build can take a few minutes, so it is recommended to use more than one CPU core:: - python setup.py build --qmake=/opt/Qt/5.14.0/gcc_64/bin/qmake --build-tests --ignore-git --parallel=8 + python setup.py build --qmake=/opt/Qt/5.15.0/gcc_64/bin/qmake --build-tests --ignore-git --parallel=8 Installing PySide2 ~~~~~~~~~~~~~~~~~~ To install on the current directory, just run:: - python setup.py install --qmake=/opt/Qt/5.14.0/gcc_64/bin/qmake --build-tests --ignore-git --parallel=8 + python setup.py install --qmake=/opt/Qt/5.15.0/gcc_64/bin/qmake --build-tests --ignore-git --parallel=8 Test installation ~~~~~~~~~~~~~~~~~ diff --git a/sources/pyside2/doc/gettingstarted-macOS.rst b/sources/pyside2/doc/gettingstarted-macOS.rst index fa6fc6037..fd1bf89f8 100644 --- a/sources/pyside2/doc/gettingstarted-macOS.rst +++ b/sources/pyside2/doc/gettingstarted-macOS.rst @@ -4,20 +4,17 @@ Getting Started on macOS Requirements ------------ - * Qt package from `here`_ or a custom build of Qt (preferably - Qt 5.12 or greater) + * Qt package from `here`_ or a custom build of Qt 5.12+ (preferably 5.15) * A Python interpreter (version Python 3.5+ or Python 2.7). You can use the one provided by HomeBrew, or you can get python from the `official website`_. * `XCode`_ 8.2 (macOS 10.11), 8.3.3 (macOS 10.12), 9 (macOS 10.13), 10.1 (macOS 10.14) * `CMake`_ version 3.1 or greater * Git version 2 or greater - * `libclang`_ from your system or the prebuilt version from the - ``Qt Downloads`` page is recommended. - * ``virtualenv`` is strongly recommended, but optional. + * `libclang`_ from your system or the prebuilt version from the ``Qt Downloads`` page is + recommended. libclang10 is required for PySide 5.15. * ``sphinx`` package for the documentation (optional). - * Depending on your OS, the following dependencies might also - be required: + * Depending on your OS, the following dependencies might also be required: * ``libgl-dev``, * ``python-dev``, @@ -37,13 +34,12 @@ Building from source Creating a virtual environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -``virtualenv`` allows you to create a local, user-writeable copy of a python environment into +The ``venv`` module allows you to create a local, user-writeable copy of a python environment into which arbitrary modules can be installed and which can be removed after use:: - virtualenv testenv + python -m venv testenv # your interpreter could be called 'python3' source testenv/bin/activate - pip install sphinx # optional: documentation - pip install numpy PyOpenGL # optional: for examples + pip install -r requirements.txt # General dependencies, documentation, and examples. will create and use a new virtual environment, which is indicated by the command prompt changing. @@ -52,12 +48,12 @@ Setting up CLANG If you don't have libclang already in your system, you can download from the Qt servers:: - wget https://download.qt.io/development_releases/prebuilt/libclang/libclang-release_60-mac-clazy.7z + wget http://download.qt.io/development_releases/prebuilt/libclang/libclang-release_100-based-mac.7z Extract the files, and leave it on any desired path, and then set these two required environment variables:: - 7z x libclang-release_60-linux-Rhel7.2-gcc5.3-x86_64-clazy.7z + 7z x libclang-release_100-based-mac.7z export CLANG_INSTALL_DIR=$PWD/libclang Getting PySide2 @@ -67,9 +63,9 @@ Cloning the official repository can be done by:: git clone --recursive https://code.qt.io/pyside/pyside-setup -Checking out the version that we want to build, e.g. 5.14:: +Checking out the version that we want to build, e.g. 5.15:: - cd pyside-setup && git checkout 5.14 + cd pyside-setup && git checkout 5.15 .. note:: Keep in mind you need to use the same version as your Qt installation @@ -77,18 +73,18 @@ Building PySide2 ~~~~~~~~~~~~~~~~ Check your Qt installation path, to specifically use that version of qmake to build PySide2. -e.g. ``/opt/Qt/5.14.0/gcc_64/bin/qmake``. +e.g. ``/opt/Qt/5.15.0/gcc_64/bin/qmake``. Build can take a few minutes, so it is recommended to use more than one CPU core:: - python setup.py build --qmake=/opt/Qt/5.14.0/gcc_64/bin/qmake --build-tests --ignore-git --parallel=8 + python setup.py build --qmake=/opt/Qt/5.15.0/gcc_64/bin/qmake --build-tests --ignore-git --parallel=8 Installing PySide2 ~~~~~~~~~~~~~~~~~~ To install on the current directory, just run:: - python setup.py install --qmake=/opt/Qt/5.14.0/gcc_64/bin/qmake --build-tests --ignore-git --parallel=8 + python setup.py install --qmake=/opt/Qt/5.15.0/gcc_64/bin/qmake --build-tests --ignore-git --parallel=8 Test installation ~~~~~~~~~~~~~~~~~ diff --git a/sources/pyside2/doc/gettingstarted-windows.rst b/sources/pyside2/doc/gettingstarted-windows.rst index 8de20769e..069358e0f 100644 --- a/sources/pyside2/doc/gettingstarted-windows.rst +++ b/sources/pyside2/doc/gettingstarted-windows.rst @@ -7,18 +7,15 @@ selected when using the online installer. Requirements ------------ - * Qt package from `here`_ or a custom build of Qt (preferably Qt 5.12 - or greater) - * A Python interpreter (version Python 3.5+). Preferably get it - from the `official website`_. + * Qt package from `here`_ or a custom build of Qt 5.12+ (preferably Qt 5.15) + * A Python interpreter (version Python 3.5+). Preferably get it from the `official website`_. * `MSVC2017`_ (or MSVC2019) for Python 3 on Windows, * `CMake`_ version 3.1 or greater * `Git`_ version 2 or greater - * `libclang`_ prebuilt version from the - ``Qt Downloads`` page is recommended. - * `OpenSSL`_ (optional for SSL support, Qt must have been - configured using the same SSL library). - * ``virtualenv`` is strongly recommended, but optional. + * `libclang`_ prebuilt version from the ``Qt Downloads`` page is recommended. We recommend + libclang10 for PySide 5.15. + * `OpenSSL`_ (optional for SSL support, Qt must have been configured using the same SSL library). + * ``venv`` or ``virtualenv`` is strongly recommended, but optional. * ``sphinx`` package for the documentation (optional). .. note:: Python 2.7 interpreter is not supported. @@ -28,6 +25,9 @@ Requirements If you intend to use Python 2.7, build the interpreter yourself with MSVC 2015 or later, and build Qt for Python with it. +.. note:: Python 3.8.0 was missing some API required for PySide/Shiboken so it's not possible + to use it for a Windows build. + .. _here: https://qt.io/download .. _official website: https://www.python.org/downloads/ @@ -44,13 +44,12 @@ Building from source on Windows 10 Creating a virtual environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -``virtualenv`` allows you to create a local, user-writeable copy of a python environment into +The ``venv`` module allows you to create a local, user-writeable copy of a python environment into which arbitrary modules can be installed and which can be removed after use:: - virtualenv testenv - call testenv\scripts\activate - pip install sphinx # optional: documentation - pip install numpy PyOpenGL # optional: for examples + python -m venv testenv + call testenv\Scripts\activate + pip install -r requirements.txt # General dependencies, documentation, and examples. will create and use a new virtual environment, which is indicated by the command prompt changing. @@ -58,7 +57,7 @@ Setting up CLANG ~~~~~~~~~~~~~~~~ If you don't have libclang already in your system, you can download from the Qt servers, -e.g. ``libclang-release_60-windows-vs2015_64-clazy.7z``. +e.g. ``libclang-release_100-based-windows-vs2019_64.7z``. Extract the files, and leave it on any desired path, e.g ``c:\``, and then set these two required environment variables:: @@ -73,9 +72,9 @@ Cloning the official repository can be done by:: git clone --recursive https://code.qt.io/pyside/pyside-setup -Checking out the version that we want to build, e.g. 5.14:: +Checking out the version that we want to build, e.g. 5.15:: - cd pyside-setup && git checkout 5.14 + cd pyside-setup && git checkout 5.15 .. note:: Keep in mind you need to use the same version as your Qt installation @@ -83,7 +82,7 @@ Building PySide2 ~~~~~~~~~~~~~~~~ Check your Qt installation path, to specifically use that version of qmake to build PySide2. -e.g. ``E:\Qt\5.12.0\msvc2015_64\bin\qmake.exe``. +e.g. ``E:\Qt\5.15.0\msvc2019_64\bin\qmake.exe``. Build can take a few minutes, so it is recommended to use more than one CPU core:: diff --git a/sources/pyside2/doc/gettingstarted.rst b/sources/pyside2/doc/gettingstarted.rst index 197657493..1623538cf 100644 --- a/sources/pyside2/doc/gettingstarted.rst +++ b/sources/pyside2/doc/gettingstarted.rst @@ -16,7 +16,7 @@ General Requirements * **Python**: 3.5+ and 2.7 * **Qt:** 5.12+ is recommended - * **libclang:** The libclang library, recommended: version 6 for PySide2 5.12. + * **libclang:** The libclang library, recommended: version 10 for PySide2 5.15. Prebuilt versions of it can be `downloaded here`_. * **CMake:** 3.1+ is needed. @@ -66,28 +66,60 @@ Other important options to consider are: * ``--doc-build-online``, to build documentation using the online template. Testing the installation -------------------------- +------------------------ Once the installation finishes, you will be able to execute any of our examples:: python examples/widgets/widgets/tetrix.py Running Tests --------------- +------------- Using the ``--build-tests`` option will enable us to run all the auto tests inside the project:: python testrunner.py test > testlog.txt .. note:: On Windows, don't forget to have qmake in your path - (``set PATH=E:\Path\to\Qt\5.14\msvc2017_64\bin;%PATH%``) + (``set PATH=E:\Path\to\Qt\5.15\msvc2017_64\bin;%PATH%``) You can also run a specific test (for example ``qpainter_test``) by running:: ctest -R qpainter_test --verbose Building the documentation ---------------------------- +-------------------------- + +Starting from 5.15, there are two options to build the documentation: + +1. Building rst-only documentation (no API) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The process of parsing Qt headers to generate the PySide API documentation can take several +minutes, this means that modifying a specific section of the rst files we currently have, might +become a hard task. + +For this, you can install ``sphinx`` on a virtual environment, and execute the following command:: + + python setup.py build_rst_docs + +which will generate a ``html/`` directory with the following structure:: + + html + └── pyside2 + ├── index.html + ├── ... + └── shiboken2 + ├── index.html + └── ... + +so you can open the main page ``html/pyside2/index.html`` on your browser to check the generated +files. + +This is useful when updating the general sections of the documentation, adding tutorials, +modifying the build instructions, and more. + +2. Building the documentation (rst + API) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The documentation is being generated using **qdoc** to get the API information, and also **sphinx** for the local Python related notes. @@ -152,7 +184,7 @@ A set of tools can be found under the ``tools/`` directory inside the ``pyside-s * ``create_changelog.py``: Script used to create the CHANGELOG that you can find in the ``dist/`` directory. Usage:: - python create_changelog.py -r 5.14.1 -v v5.14.0..5.14 -t bug-fix + python create_changelog.py -r 5.15.1 -v v5.15.0..5.15 -t bug-fix * ``debug_windows.py``: This script can be used to find out why PySide2 modules fail to load with various DLL errors like Missing DLL or Missing symbol in DLL. @@ -174,7 +206,7 @@ A set of tools can be found under the ``tools/`` directory inside the ``pyside-s regarding available modules and classses. This content is displayed in our `wiki page`_, and can be used as follows:: - python missing_bindings.py --qt-version 5.14.1 -w all + python missing_bindings.py --qt-version 5.15.1 -w all Please keep in mind we rely on BeautifulSoup_ to parse the content, so you will be to install it besides PySide2 and PyQt5 (Including additional modules like DataVisualiztion, QtCharts, diff --git a/sources/pyside2/doc/index.rst b/sources/pyside2/doc/index.rst index ed5aeb6b4..6c62334d5 100644 --- a/sources/pyside2/doc/index.rst +++ b/sources/pyside2/doc/index.rst @@ -3,20 +3,30 @@ .. ifconfig:: output_format == 'html' - **Qt for Python** offers the official Python bindings for `Qt`_ (`PySide2`_), - so that you can use Qt5 APIs in your Python applications, and a binding generator tool - (`Shiboken2 <shiboken2/index.html>`__) which can be used to expose C++ projects into Python. + **Qt for Python** offers the official Python bindings for `Qt`_, and + has two main components: + + * `PySide2`_, so that you can use Qt5 APIs in your Python applications, and + * `Shiboken2 <shiboken2/index.html>`__, a binding generator tool, which can + be used to expose C++ projects to Python, and a Python module with + some utility functions. .. ifconfig:: output_format == 'qthelp' - **Qt for Python** offers the official Python bindings for `Qt`_ (`PySide2`_), - so that you can use Qt5 APIs in your Python applications, and a binding generator tool - (`Shiboken2 <../shiboken2/index.html>`__) which can be used to expose C++ projects into Python. + **Qt for Python** offers the official Python bindings for `Qt`_, and + has two main components: + + * `PySide2`_, so that you can use Qt5 APIs in your Python applications, and + * `Shiboken2 <../shiboken2/index.html>`__, a binding generator tool, which can + be used to expose C++ projects to Python, and a Python module with + some utility functions. -|project| is available under the LGPLv3/GPLv3 and the Qt commercial license. +This project is available under the LGPLv3/GPLv3 and the `Qt commercial license`_. .. _Qt: https://doc.qt.io .. _PySide2: quickstart.html +.. _`Qt commercial license`: https://www.qt.io/licensing/ + Documentation diff --git a/sources/pyside2/doc/quickstart.rst b/sources/pyside2/doc/quickstart.rst index b6a3dbbb3..87471a8a8 100644 --- a/sources/pyside2/doc/quickstart.rst +++ b/sources/pyside2/doc/quickstart.rst @@ -6,22 +6,37 @@ Requirements Before you can install |project|, first you must install the following software: - * Python 2.7 or 3.5+, + * Python 2.7 or 3.5+ (we recommend 3.5+), * We recommend using a virtual environment, such as `venv <https://docs.python.org/3/library/venv.html>`_ or `virtualenv <https://virtualenv.pypa.io/en/latest>`_ +Creating and activating an environment +-------------------------------------- + +You can do this by running the following on a terminal:: + + $ python -m venv env/ # Your binary is maybe called 'python3' + $ source env/bin/activate # for Linux and macOS + $ env\Scripts\activate.bat # for Windows + + + Installation ------------ Now you are ready to install the |project| packages using ``pip``. From the terminal, run the following command:: - pip install PySide2 # For the latest version on PyPi + # For the latest version on PyPi + pip install PySide2 + + # For a specific version + pip install PySide2==5.15.0 or:: - pip install --index-url=http://download.qt.io/snapshots/ci/pyside/5.14/latest pyside2 --trusted-host download.qt.io + pip install --index-url=http://download.qt.io/snapshots/ci/pyside/5.15/latest pyside2 --trusted-host download.qt.io Test your Installation ---------------------- @@ -32,20 +47,16 @@ constructs to print version information:: import PySide2.QtCore # Prints PySide2 version - # e.g. 5.11.1a1 print(PySide2.__version__) - # Gets a tuple with each version component - # e.g. (5, 11, 1, 'a', 1) - print(PySide2.__version_info__) - # Prints the Qt version used to compile PySide2 - # e.g. "5.11.2" print(PySide2.QtCore.__version__) - # Gets a tuple with each version components of Qt used to compile PySide2 - # e.g. (5, 11, 2) - print(PySide2.QtCore.__version_info__) +.. note:: + + As it happened in 5.14.2, PySide had a couple of new releases to fix + issues in 5.14.2, adding yet another version level. In that case, you + will have different versions being shown for Qt and PySide. Create a Simple Application --------------------------- @@ -73,8 +84,8 @@ guide you through the development process: self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"] self.button = QtWidgets.QPushButton("Click me!") - self.text = QtWidgets.QLabel("Hello World") - self.text.setAlignment(QtCore.Qt.AlignCenter) + self.text = QtWidgets.QLabel("Hello World", + alignment=QtCore.Qt.AlignCenter) self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.text) @@ -83,7 +94,7 @@ guide you through the development process: self.button.clicked.connect(self.magic) - + @QtCore.Slot() def magic(self): self.text.setText(random.choice(self.hello)) diff --git a/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst b/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst index 804905eb8..982384629 100644 --- a/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst +++ b/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst @@ -1,5 +1,5 @@ -Using `.ui` Files (`QUiLoader` and `pyside2-uic`) -************************************************* +Using `.ui` files from Designer or QtCreator with `QUiLoader` and `pyside2-uic` +******************************************************************************* This page describes the use of Qt Creator to create graphical interfaces for your Qt for Python project. @@ -13,8 +13,9 @@ At Qt Creator, create a new Qt Design Form, choose "Main Window" for template. And save as `mainwindow.ui`. Add a `QPushButton` to the center of the centralwidget. -Your file (mainwindow.ui) should look something like this: -:: +Your file ``mainwindow.ui`` should look something like this: + +.. code-block:: xml <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> @@ -73,8 +74,8 @@ Your file (mainwindow.ui) should look something like this: Now we are ready to decide how to use the **UI file** from Python. -Generating a Python class -========================= +Option A: Generating a Python class +=================================== Another option to interact with a **UI file** is to generate a Python class from it. This is possible thanks to the `pyside2-uic` tool. @@ -128,8 +129,8 @@ file: You must run `pyside2-uic` again every time you make changes to the **UI file**. -Loading it directly -==================== +Option B: Loading it directly +============================= To load the UI file directly, we will need a class from the **QtUiTools** module: diff --git a/sources/pyside2/doc/tutorials/index.rst b/sources/pyside2/doc/tutorials/index.rst index 9739eee97..a159725a7 100644 --- a/sources/pyside2/doc/tutorials/index.rst +++ b/sources/pyside2/doc/tutorials/index.rst @@ -11,7 +11,7 @@ Basic tutorials --------------- .. toctree:: - :maxdepth: 2 + :maxdepth: 1 basictutorial/widgets.rst basictutorial/qml.rst @@ -25,7 +25,7 @@ Real use-cases applications --------------------------- .. toctree:: - :maxdepth: 2 + :maxdepth: 1 datavisualize/index.rst expenses/expenses.rst @@ -37,6 +37,6 @@ C++ and Python -------------- .. toctree:: - :maxdepth: 2 + :maxdepth: 1 portingguide/index.rst diff --git a/sources/pyside2/doc/videos.rst b/sources/pyside2/doc/videos.rst index 511bc0d66..5c72c90df 100644 --- a/sources/pyside2/doc/videos.rst +++ b/sources/pyside2/doc/videos.rst @@ -1,93 +1,96 @@ |project| Videos ================ -Webinar: Creating user interfaces with Qt for Python ----------------------------------------------------- - -.. raw:: html - - <div style="position: relative; padding-bottom: 56.25%; height: 0; - overflow: hidden; max-width: 100%; height: auto;"> - <iframe src="https://www.youtube.com/embed/wKqLaNqxgas" frameborder="0" - allowfullscreen style="position: absolute; top: 0; left: 0; - width: 100%; height: 100%;"> - </iframe> - </div> - -Webinar: Develop your first Qt for Python application ------------------------------------------------------ - -.. raw:: html - - <div style="position: relative; padding-bottom: 56.25%; height: 0; - overflow: hidden; max-width: 100%; height: auto;"> - <iframe src="https://www.youtube.com/embed/HDBjmSiOBxY" frameborder="0" - allowfullscreen style="position: absolute; top: 0; left: 0; - width: 100%; height: 100%;"> - </iframe> - </div> - -Webinar: Python and C++ interoperability with Shiboken ------------------------------------------------------- - -.. raw:: html - - <div style="position: relative; padding-bottom: 56.25%; height: 0; - overflow: hidden; max-width: 100%; height: auto;"> - <iframe src="https://www.youtube.com/embed/wOMlDutOWXI" frameborder="0" - allowfullscreen style="position: absolute; top: 0; left: 0; - width: 100%; height: 100%;"> - </iframe> - </div> - -QtWS2018: Mastering Qt for Python in 20 min --------------------------------------------- - -.. raw:: html - - <div style="position: relative; padding-bottom: 56.25%; height: 0; - overflow: hidden; max-width: 100%; height: auto;"> - <iframe src="https://www.youtube.com/embed/IhxZ99usPqY" frameborder="0" - allowfullscreen style="position: absolute; top: 0; left: 0; - width: 100%; height: 100%;"> - </iframe> - </div> - -QtWS2019: Utilizing Shiboken to Enhance your Qt for Python Application ----------------------------------------------------------------------- - -.. raw:: html - - <div style="position: relative; padding-bottom: 56.25%; height: 0; - overflow: hidden; max-width: 100%; height: auto;"> - <iframe src="https://www.youtube.com/embed/mAfEVPgHRt8" frameborder="0" - allowfullscreen style="position: absolute; top: 0; left: 0; - width: 100%; height: 100%;"> - </iframe> - </div> - -QtWS2019: Introduction to Qt for Python ---------------------------------------- - -.. raw:: html - - <div style="position: relative; padding-bottom: 56.25%; height: 0; - overflow: hidden; max-width: 100%; height: auto;"> - <iframe src="https://www.youtube.com/embed/214TWASZVgA" frameborder="0" - allowfullscreen style="position: absolute; top: 0; left: 0; - width: 100%; height: 100%;"> - </iframe> - </div> - -QtWS2019: How to bring your C++ project to Python land ------------------------------------------------------- - .. raw:: html - <div style="position: relative; padding-bottom: 56.25%; height: 0; - overflow: hidden; max-width: 100%; height: auto;"> - <iframe src="https://www.youtube.com/embed/XmY-tWTi9gY" frameborder="0" - allowfullscreen style="position: absolute; top: 0; left: 0; - width: 100%; height: 100%;"> + <style> + .embed-container { + margin-top: 10px; + position: relative; + padding-bottom: 56.25%; + height: 0; + overflow: hidden; + max-width: 100%; + } + .embed-container iframe, .embed-container object, .embed-container embed { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + } + .video-title { + font-weight: bold; + text-align: center; + } + </style> + <table> + <tr> + <td style="width: 30%;"> + <p class="video-title">QtVirtualTechCon2020: From Prototypes to Hybrid Applications</p> + <div class="embed-container"> + <iframe src="https://www.youtube.com/embed/Vb1dbLQafyM" frameborder="0" allowfullscreen> + </iframe> + </div> + </td> + <td style="width: 30%;"> + <p class="video-title">QtWS2019: Utilizing Shiboken to Enhance your Application</p> + <div class='embed-container'> + <iframe src="https://www.youtube.com/embed/mAfEVPgHRt8" frameborder="0" allowfullscreen> + </iframe> + </div> + </td> + <td style="width: 30%;"> + <p class="video-title">QtWS2019: Introduction to Qt for Python</p> + <div class='embed-container'> + <iframe src="https://www.youtube.com/embed/214TWASZVgA" frameborder="0" allowfullscreen> + </iframe> + </div> + </td> + </tr> + </tr> + <td style="width: 30%;"> + <p class="video-title">Webinar: Python and C++ interoperability with Shiboken</p> + <div class='embed-container'> + <iframe src="https://www.youtube.com/embed/wOMlDutOWXI" frameborder="0" allowfullscreen> + </iframe> + </div> + </td> + <td style="width: 30%;"> + <p class="video-title">QtWS2019: How to bring your C++ project to Python land</p> + <div class='embed-container'> + <iframe src="https://www.youtube.com/embed/XmY-tWTi9gY" frameborder="0" allowfullscreen> + </iframe> + </div> + </td> + <td style="width: 30%;"> + <p class="video-title">QtWS2018: Mastering Qt for Python in 20 min</p> + <div class='embed-container'> + <iframe src="https://www.youtube.com/embed/IhxZ99usPqY" frameborder="0" allowfullscreen> </iframe> - </div> + </td> + </tr> + </tr> + <td style="width: 30%;"> + <p class="video-title">Webinar: Develop your first Qt for Python application</p> + <div class='embed-container'> + <iframe src="https://www.youtube.com/embed/HDBjmSiOBxY" frameborder="0" allowfullscreen> + </iframe> + </div> + </td> + <td style="width: 30%;"> + <p class="video-title">Webinar: Creating user interfaces with Qt for Python</p> + <div class='embed-container'> + <iframe src="https://www.youtube.com/embed/wKqLaNqxgas" frameborder="0" allowfullscreen> + </iframe> + </div> + </td> + <td style="width: 30%;"> + <p class="video-title">QtWS2017: Take a walk on the PySide</p> + <div class="embed-container"> + <iframe src="https://www.youtube.com/embed/Sb4FV6SdHHQ" frameborder="0" allowfullscreen> + </iframe> + </div> + </td> + </tr> + </table> diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index be285693e..75fd6af5b 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -1278,7 +1278,9 @@ void AbstractMetaBuilderPrivate::fixReturnTypeOfConversionOperator(AbstractMetaF if (!retType) return; - metaFunction->replaceType(new AbstractMetaType(retType)); + auto metaType = new AbstractMetaType(retType); + metaType->decideUsagePattern(); + metaFunction->replaceType(metaType); } AbstractMetaFunctionList AbstractMetaBuilderPrivate::classFunctionList(const ScopeModelItem &scopeItem, diff --git a/sources/shiboken2/doc/gettingstarted.rst b/sources/shiboken2/doc/gettingstarted.rst index caeb5a909..321db9545 100644 --- a/sources/shiboken2/doc/gettingstarted.rst +++ b/sources/shiboken2/doc/gettingstarted.rst @@ -12,8 +12,8 @@ General Requirements ^^^^^^^^^^^^^^^^^^^^ * **Python**: 3.5+ and 2.7 - * **Qt:** 5.12+ is recommended - * **libclang:** The libclang library, recommended: version 6 for Shiboken2 5.12. + * **Qt:** 5.12+ (5.15 is recommended) + * **libclang:** The libclang library, recommended: version 10 for Shiboken2 5.15. Prebuilt versions of it can be `downloaded here`_. * **CMake:** 3.1+ is needed. @@ -24,15 +24,26 @@ Simple build If you need only Shiboken Generator, a simple build run would look like this:: + # For the required libraries (this will also build the shiboken2 python module) + python setup.py install --qmake=/path/to/qmake \ + --build-tests \ + --verbose-build \ + --internal-build-type=shiboken2 + + # For the executable python setup.py install --qmake=/path/to/qmake \ --build-tests \ - --parallel=8 \ --verbose-build \ --internal-build-type=shiboken2-generator The same can be used for the module, changing the value of ``internal-build-type`` to ``shiboken2-module``. +.. warning:: If you are planning to use PySide too, for examples like + 'scriptableapplication' you need to have build it as well. The main issue is + that your PySide and Shiboken needs to be build using the same dependencies + from Qt and libclang. + Using the wheels ---------------- diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 434b03dc7..11a6c193e 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -1622,20 +1622,39 @@ void CppGenerator::writeConverterRegister(QTextStream &s, const AbstractMetaClas s << Qt::endl; - QStringList cppSignature; - if (!classContext.forSmartPointer()) { - cppSignature = metaClass->qualifiedCppName().split(QLatin1String("::"), - Qt::SkipEmptyParts); - } else { - cppSignature = classContext.preciseType()->cppSignature().split(QLatin1String("::"), - Qt::SkipEmptyParts); - } - while (!cppSignature.isEmpty()) { - QString signature = cppSignature.join(QLatin1String("::")); + auto writeConversions = [&s, this](const QString &signature) + { s << INDENT << "Shiboken::Conversions::registerConverterName(converter, \"" << signature << "\");\n"; s << INDENT << "Shiboken::Conversions::registerConverterName(converter, \"" << signature << "*\");\n"; s << INDENT << "Shiboken::Conversions::registerConverterName(converter, \"" << signature << "&\");\n"; - cppSignature.removeFirst(); + }; + + auto writeConversionsForType = [writeConversions](const QString &fullTypeName) + { + QStringList lst = fullTypeName.split(QLatin1String("::"), + Qt::SkipEmptyParts); + while (!lst.isEmpty()) { + QString signature = lst.join(QLatin1String("::")); + writeConversions(signature); + lst.removeFirst(); + } + }; + + if (!classContext.forSmartPointer()) { + writeConversionsForType(metaClass->qualifiedCppName()); + } else { + const QString &smartPointerType = classContext.preciseType()->instantiations().at(0)->cppSignature(); + const QString &smartPointerName = classContext.preciseType()->typeEntry()->name(); + + QStringList lst = smartPointerType.split(QLatin1String("::"), + Qt::SkipEmptyParts); + while (!lst.isEmpty()) { + QString signature = lst.join(QLatin1String("::")); + writeConversions(QStringLiteral("%1<%2>").arg(smartPointerName, signature)); + lst.removeFirst(); + } + + writeConversionsForType(smartPointerType); } s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::"; diff --git a/sources/shiboken2/tests/libsmart/smart_sharedptr.h b/sources/shiboken2/tests/libsmart/smart_sharedptr.h index 84184e1f8..65a489c68 100644 --- a/sources/shiboken2/tests/libsmart/smart_sharedptr.h +++ b/sources/shiboken2/tests/libsmart/smart_sharedptr.h @@ -29,19 +29,9 @@ #ifndef SMART_SHARED_PTR_H #define SMART_SHARED_PTR_H -#include "libsmartmacros.h" +#include <memory> -template <class T> -class RefData { -public: - RefData(T *ptr) : m_refCount(1), m_heldPtr(ptr) {} - ~RefData() { delete m_heldPtr; } - int inc() { return ++m_refCount; } - int dec() { return --m_refCount; } - int useCount() { return m_refCount; } - int m_refCount; - T *m_heldPtr; -}; +#include "libsmartmacros.h" struct SharedPtrBase { @@ -57,84 +47,70 @@ class SharedPtr : public SharedPtrBase { public: SharedPtr() { logDefaultConstructor(this); } - SharedPtr(T *v) + SharedPtr(T *v) : mPtr(v) { logConstructor(this, v); - if (v) - m_refData = new RefData<T>(v); } - SharedPtr(const SharedPtr<T> &other) : m_refData(other.m_refData) + SharedPtr(const SharedPtr<T> &other) : mPtr(other.mPtr) { - logCopyConstructor(this, other.m_refData); - if (m_refData) - m_refData->inc(); + logCopyConstructor(this, data()); } - SharedPtr<T> &operator=(const SharedPtr<T>& other) + template<class X> + SharedPtr(const SharedPtr<X> &other) : mPtr(other.mPtr) { - if (this != &other) { - logAssignment(this, other.m_refData); - if (m_refData && m_refData->dec() == 0) - delete m_refData; - m_refData = other.m_refData; - if (m_refData) - m_refData->inc(); - } + logCopyConstructor(this, data()); + } + + SharedPtr& operator=(const SharedPtr& other) + { + mPtr = other.mPtr; return *this; } T *data() const { - return m_refData ? m_refData->m_heldPtr : nullptr; + return mPtr.get(); } int useCount() const { - return m_refData ? m_refData->useCount() : 0; + return mPtr.use_count(); } void dummyMethod1() { + } + bool isNull() const + { + return mPtr.get() == nullptr; } T& operator*() const { // Crashes if smart pointer is empty (just like std::shared_ptr). - return *(m_refData->m_heldPtr); + return *mPtr; } T *operator->() const { - return m_refData ? m_refData->m_heldPtr : nullptr; + return mPtr.get(); } bool operator!() const { - return !m_refData || !m_refData->m_heldPtr; - } - - bool isNull() const - { - return !m_refData || !m_refData->m_heldPtr; - } - - operator bool() const - { - return m_refData && m_refData->m_heldPtr; + return !mPtr; } ~SharedPtr() { - if (m_refData) - logDestructor(this, m_refData->useCount() - 1); - if (m_refData && m_refData->dec() == 0) - delete m_refData; + if (mPtr.use_count() >= 1) + logDestructor(this, mPtr.use_count() - 1); } -private: - RefData<T> *m_refData = nullptr; + std::shared_ptr<T> mPtr; }; #endif // SMART_SHARED_PTR_H diff --git a/sources/shiboken2/tests/smartbinding/typesystem_smart.xml b/sources/shiboken2/tests/smartbinding/typesystem_smart.xml index 8fb3082a0..46cb08267 100644 --- a/sources/shiboken2/tests/smartbinding/typesystem_smart.xml +++ b/sources/shiboken2/tests/smartbinding/typesystem_smart.xml @@ -34,6 +34,7 @@ </conversion-rule> </container-type> + <custom-type name="std::shared_ptr" /> <!-- Used in tests to check what C++ objects are allocated. --> <object-type name="Registry" /> |