ENH: Restore CTK_USE_QTTESTING support for Qt 6 (#1314) - #1379
Merged
Conversation
hjmjohnson
marked this pull request as draft
March 28, 2026 13:33
hjmjohnson
force-pushed
the
fix/issue-1314
branch
2 times, most recently
from
March 28, 2026 15:35
5556696 to
45ef4bd
Compare
hjmjohnson
marked this pull request as ready for review
March 28, 2026 15:36
hjmjohnson
force-pushed
the
fix/issue-1314
branch
2 times, most recently
from
March 28, 2026 17:02
8a46811 to
f872a59
Compare
Contributor
|
@hjmjohnson Some minor merge conflicts to resolve post-QRegularExpression update |
Contributor
|
I wasn't allowed to push to |
C++17 is highly recommended for Qt5.15 and is required for Qt6.
(ctk-2026-03-27), which includes:
- Qt 6 CMake support from commontk HEAD (4bdc580)
- QFlags int() casts for Qt 6.11 QString::arg() compatibility
(implicit QFlags→int conversion was removed in Qt 6.11)
- C++17 standard enforcement in QtTesting CMakeLists
Remove the block that forced CTK_USE_QTTESTING=OFF when building with Qt 6. The QtXmlPatterns dependency that prevented Qt 6 support has been isolated to ctkXMLEventSource (addressed separately), so CTK_USE_QTTESTING can now be enabled for Qt 6 users.
The upstream QtTesting target name changed from "QtTesting" (pre-2024) to lowercase "qttesting" in newer revisions. Add an if(TARGET qttesting) check in Libs/QtTesting, Libs/Widgets, and Libs/Visualization/VTK/Widgets so both the old Qt5 pin and the new Qt6-compatible revision link correctly. Changes suggested by AI coding tools
QXmlSchema and QXmlSchemaValidator are from the QtXmlPatterns module which does not exist in Qt 6. Guard their includes and usage behind \#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0). The rest of the file (QXmlStreamReader) is already Qt 6 compatible.
Qt 6 removed the XmlPatterns module. Guard the Qt5::XmlPatterns target_link_libraries entry so it is only added for Qt 5 builds. ctkXMLEventSource already guards its XmlPatterns usage at the source level. Changes suggested by AI coding agent
QInputEvent::operator= is protected in Qt 6, making QMouseEvent members non-assignable. Change lastMoveEvent, oldMoveEvent, and lastMouseEvent from QMouseEvent value members to std::optional<QMouseEvent> so that .emplace() can be used for in-place construction instead of copy-assign. Update all access sites to use -> dereference. Changes suggested by AI coding tools
hjmjohnson
force-pushed
the
fix/issue-1314
branch
from
March 28, 2026 20:18
f872a59 to
9a77658
Compare
jamesobutler
approved these changes
Mar 28, 2026
jamesobutler
enabled auto-merge (rebase)
March 28, 2026 20:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #1314.
CTK_USE_QTTESTINGwas forcibly disabled for Qt 6 builds becausectkXMLEventSourcedepended on Qt XmlPatterns, which is unavailable in Qt 6. This PR removes that restriction through a series of targeted, independent fixes.Commits
COMP: Set CMAKE_CXX_STANDARD for Qt supportENH: Update QtTesting with Qt 6 supportint()casts forQFlags→QString::arg()(Qt 6.11 removed implicit conversion), and C++17 enforcement in QtTesting's CMakeLists.ENH: Allow CTK_USE_QTTESTING=ON with Qt 6 buildsCMakeLists.txtthat forcedCTK_USE_QTTESTING=OFFfor Qt 6COMP: Guard ctkXMLEventSource XmlPatterns usage for Qt 6QXmlSchema/QXmlSchemaValidatorincludes and usage behind#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)— the rest of the file (QXmlStreamReader) is Qt 6 compatibleCOMP: Guard Qt5::XmlPatterns link dependency for Qt 6 buildsQt5::XmlPatternsentry inLibs/QtTesting/CMakeLists.txtso it is only added for Qt 5 buildsCOMP: Detect both QtTesting and qttesting CMake target namesQtTesting(pre-2024) toqttesting(lowercase) in newer revisions; addif(TARGET qttesting)checks inLibs/QtTesting,Libs/Widgets, andLibs/Visualization/VTK/WidgetsCOMP: Fix ctkVTKRenderViewEventTranslator for Qt 6 (protected operator=)QInputEvent::operator=is protected in Qt 6, makingQMouseEventvalue members non-assignable; change tostd::optional<QMouseEvent>and use.emplace()for in-place constructionBUG: Replace QRegExp with QRegularExpression in ITK logging testQRegExpwas removed in Qt 6; replace withQRegularExpressionand updateexactMatch()→regexp.match(...).hasMatch()Verification
Qt 6.11.0 build verified on macOS ARM64 with
CTK_USE_QTTESTING=ON:libCTKQtTesting.dylibbuilds and links successfully.Test plan
CTK_USE_QTTESTING=ON: confirm no regressionsCTK_USE_QTTESTING=ON: confirm QtTesting builds and links successfully