Qtitan Components for PySide2/PySide6 - Quickstart Guide
Qtitan Components for PySide2/PySide6 - Quickstart Guide
Topic describes how to include the Qtitan components for the regular Python App. The steps described in this topic are relevant to any Qtitan component - QtitanRibbon, QtitanDataGrid, QtitanNavigationDesignUI, QtitanChart, QtitanDocking.
Prerequisites
To use Qtitan Component for Python, you'll need:
- Python3.6 or higher installed from here https://www.python.org
- MS Visual Studio or Qt-Creator
- PySide2/PySide6 and shiboken2/shiboken6 are needed to be installed as described here https://wiki.qt.io/Qt_for_Python/GettingStarted
- If you will need to rebuild the Python bingings for Qtitan components you have to install shiboken2-generator package. You can find the wheels for shiboken2-generator/shiboken6-generator by this link: https://download.qt.io/official_releases/QtForPython/shiboken2-generator/
Step 1: Install Qtitan Component for Python
- Goto to the page https://www.devmachines.com/download-for-qt.html
- Download the installer for platform you use. Components that are needed for Python have the suffix PySide in the installer name. Suffix PySide2 for Qt5 or suffix PySide6 if you use Qt6.
- Install it following the recommendations of the installer wizard.
- After install process you'll have python bindings in the <QTITAN_INSTALL_PATH>site-packages/DevMachines folder.
Additionally the bindings will be installed to the your Python third-party libraries folder where the PySide2 or PySide6 was installed. For instance: c:\Python\Python37-32\Lib\site-packages\PySide2 c:\Python\Python37-32\Lib\site-packages\shiboken2 c:\Python\Python37-32\Lib\site-packages\DevMachines
To get Python site-packages directory for your environment execute the following command line in the shell:
python -c "import site; print(site.getsitepackages())"
Step 2: Add component to your Python file (*.py)
Add the Qtitan Component to the Python file. All components in the DevMachines namespace.
from DevMachines.QtitanBase import WindowTitleBar from DevMachines.QtitanRibbon import AdobePhotoshopStyle, Office2016Style
By analogy for other Qtitan components:
from DevMachines.QtitanGrid import Grid from DevMachines.QtitanNavigationDesignUI import NavigationView
In addition, it is possible to quickly check for which environment the current Qtitan python modules are intended:
from DevMachines import __pyside2__, __pyside6__ if __pyside2__: print("Python for Qt5") if __pyside6__: print("Python for Qt6")
Step 3: Run you Python App
Run your Python App and make sure that there are no any errors and warnings.
Building the Qtitan Component binding for Python from sources
Topic describes how to build the Qtitan components bindings for Python from sources.
CLang
For building Qitan components for PySide2 or PySide6, you must have Clang version 10 installed at the build machine. Make sure the environment variable LLVM_INSTALL_DIR is initialized and points to the correct location. To check the Clang version that is currently installed, you can use this command:
C:\QtitanInstallDir>clang -v clang version 10.0.0 Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: c:\Program Files\LLVM_10\bin
PySide2 or PySide6
For the correct compilling the Qtitan Components bindings for python, either PySide2 or PySide6 should be installed. To install use the command:
\\Installation PySide2 pip install pyside2 shiboken2 pip install --index-url=https://download.qt.io/official_releases/QtForPython/ --trusted-host download.qt.io shiboken2_generator
\\Installation PySide6 pip install pyside6 shiboken6 pip install --index-url=https://download.qt.io/official_releases/QtForPython/ --trusted-host download.qt.io shiboken6_generator
Windows Visual Studio
To build for Windows OS you have to use Visual Studio Toolkit 2015 (v140) to buld the bindings for PySide2 and Visual Studio Toolkit 2019 (v142) for PySide6. If you will use incompatible toolkits, you will have C++ errors during compilation.
Building from command line
Open the bat shell. "Windows logo key" + R, cmd.exe Set current directory to the <QTITAN_INSTALL_PATH>. C:/>dir <QTITAN_INSTALL_PATH>
//PySide2 vcvars32_2015.bat qmake.exe -r CONFIG+=python -platform win32-msvc nmake release
//PySide6 vcvars64.bat qmake.exe -r CONFIG+=python -platform win32-msvc nmake release
After the build process you will have a new binding libraries in the <QTITAN_INSTALL_PATH>site-packages/DevMachines folder.
Building from Visual Studio environment
To generate a project for Microsoft Visual Studio, use the command:
vcvars64.bat qmake.exe -tp vc -r CONFIG+=python -platform win32-msvc
After that you will have <QTITAN_INSTALL_PATH>/Python.QtitanComponents.sln solution file.