-
Notifications
You must be signed in to change notification settings - Fork 513
Add support for Qt 6 alongside Qt 5 #1309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Time to update the CI to also build a job with Qt6? Line 42 in dd4caea
|
|
Supersede the following: |
Ditto. I will do so in the next hour or so. |
d1e2171 to
87c81de
Compare
|
Issue specific to older Qt version using a stricter |
|
Similarly to #1309 (comment), additional issues related to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces support for Qt 6 while maintaining backward compatibility with Qt 5. The implementation uses the CTK_QT_VERSION variable to conditionally configure CMake for either Qt version, with automatic detection defaulting to Qt 6 when Qt6_DIR is defined.
Key changes:
- Generalized CMake macros to handle both Qt 5 and Qt 6 using
CTK_QT_VERSIONvariable - Added Qt 6-specific components (Core5Compat, StateMachine, OpenGLWidgets, DesignerComponentsPrivate)
- Disabled features that depend on Qt components unavailable in Qt 6 (XmlPatterns, QtSOAP)
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| CMakeLists.txt | Adds Qt version auto-detection, validation, and conditional disabling of Qt 6-incompatible features |
| CMake/ctkMacroSetupQt.cmake | Updates Qt package discovery and component selection for both Qt 5 and Qt 6 |
| CMake/ctkMacroSetupPlugins.cmake | Generalizes Qt library path detection for both versions |
| CMake/ctkMacroBuildQtPlugin.cmake | Updates Qt Designer plugin support and compile definitions for Qt 6 |
| CMake/ctkMacroBuildPlugin.cmake | Replaces Qt5-specific functions with version-agnostic equivalents |
| CMake/ctkFunctionGeneratePluginManifest.cmake | Updates resource compilation to use generic Qt function |
| Libs/Core/CMakeLists.txt | Adds Qt 6-specific dependencies (Core5Compat, StateMachine) |
| Libs/Widgets/CMakeLists.txt | Adds Qt 6-specific OpenGLWidgets component |
| Libs/Widgets/Testing/Cpp/CMakeLists.txt | Generalizes Qt Test and XmlPatterns linking for both versions |
| Libs/Visualization/VTK/Widgets/target_libraries.cmake | Adds Qt 6 network and webkit library references |
| Libs/PluginFramework/Documentation/Snippets/EventAdmin-Intro/files.cmake | Replaces Qt5-specific moc wrapper with generic version |
| .github/workflows/ci.yml | Adds Qt 6 CI matrix testing alongside Qt 5 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This change updates various CMake macros to handle Qt6 by using CTK_QT_VERSION. It replaces hardcoded Qt5 references with version-agnostic code where possible.
Qt5’s `Qt5Designer_DEFINITIONS` and related variables may contain generator expressions that are not compatible with direct `add_definitions()` usage. This change documents why we continue using `add_definitions()` and `include_directories()` for Qt5, and relies on target usage requirements for newer Qt versions instead of failing with a fatal error.
Enable building CTK with either Qt 5 or Qt 6 by updating CMake
configuration and Qt component selection:
* Allow `CTK_QT_VERSION` to be 5 or 6 (defaulting to 6 when `Qt6_DIR`
is defined, otherwise 5), and validate its value.
* Use common Qt APIs for both Qt 5 and Qt 6 where available
(e.g. `qt_add_resources`, `qt_create_translation`,
`qt_wrap_cpp`, plugin setup helpers).
* Add required Qt 6 components when building with Qt 6, including
`Core5Compat`, `StateMachine`, and `OpenGLWidgets`, while preserving
existing Qt 5 behavior.
* Restrict use of deprecated or Qt 5–only components:
* Require `XmlPatterns` only with Qt 5.
* Force `CTK_USE_QTTESTING` OFF with Qt 6, since QtTesting depends on
`XmlPatterns`.
* Disable CommandLine Modules components and applications that depend
on `XmlPatterns` for Qt 6 builds.
* Disable DICOM Application Hosting plug-ins and example applications
that depend on QtSOAP for Qt 6 builds.
* Update core, widgets, VTK widgets, and test CMakeLists to link against
the appropriate Qt 5/Qt 6 targets based on `CTK_QT_VERSION`.
Co-authored-by: Stefan Dinkelacker <[email protected]>
Co-authored-by: jporcher <[email protected]>
Co-authored-by: Hans Johnson <[email protected]>
- Extend matrix with qt-major-version (5, 6) to exercise both Qt versions. - Split Qt install into Qt 5 and Qt 6 steps conditioned on qt-major-version. - Keep using system VTK only for Qt 5 builds; disable it for Qt 6 builds. - Derive CTK_QT_VERSION from qt-major-version in the configure step. - Update diagnostic step to print both Qt5_DIR and Qt6_DIR from CMake cache.
This pull request introduces support for Qt 6 while maintaining compatibility with Qt 5. The changes include:
CTK_QT_VERSIONvariable.Fixes #947
Add CMake configuration for Qt6 alongside Qt5
Enable building CTK with either Qt 5 or Qt 6 by updating CMake configuration and Qt component selection:
CTK_QT_VERSIONto be 5 or 6 (defaulting to 6 whenQt6_DIRis defined, otherwise 5), and validate its value.qt_add_resources,qt_create_translation,qt_wrap_cpp, plugin setup helpers).Core5Compat,StateMachine, andOpenGLWidgets, while preserving existing Qt 5 behavior.XmlPatternsonly with Qt 5.CTK_USE_QTTESTINGOFF with Qt 6, since QtTesting depends onXmlPatterns.XmlPatternsfor Qt 6 builds.CTK_QT_VERSION.Related pull requests:
CTK updates
CTK updates
For future reference, the following pull requests fix deprecation warnings and are step toward supporting Qt6 and beyond:
PythonQt Updates (both upstream and our fork)
PythonQt Updates
commont/PythonQt: commontk/PythonQt@f4769f1...patched-v3.6.1-2025-09-30-f4769f190Upstream:
stdin,stdout, andstderrredirection in PythonQt MeVisLab/pythonqt#286PyInt_*toPyLong_*(Python 3) MeVisLab/pythonqt#310sys.flags(verbose/optimize) on Python >= 3.12; fallback to legacy globals MeVisLab/pythonqt#311Upstream (generator):