Skip to content

Conversation

@hjmjohnson
Copy link
Contributor

The AUTO* cmake support removes Qt5 specific wrapping
mechanisms that would be different in Qt6. Qt6 has
more strict dependence on full class type definitions
that are more easily managed with the AUTO* cmake
builds.

Add Q_OBJECT macro to relevant classes and include .moc files

Ensure QObject-derived classes properly use the Q_OBJECT macro for
meta-object functionality and include corresponding .moc files to
support Qt's meta-object compiler.

Add missing Q_OBJECT to complete Qt inheritance

The Q_OBJECT macro is mandatory for any class that:
• Inherits from QObject
• Uses signals or slots
• Declares properties (Q_PROPERTY)
• Needs qobject_cast, metaObject(), or other Qt RTTI features

Without it:
• Qt’s meta-object compiler (moc) won’t generate necessary code
• You may encounter runtime errors or silently broken signals/slots
• Clazy and Qt's build system may warn or fail

Need to include full class definitions instead of forward definitions.
Replace forward declarations that were common in Qt 5, but are now
discouraged in Qt 6.

Full declarations are required when the Q_OBJECT macro
is included as recommended to respect the Qt inheritance
expectations.

@hjmjohnson
Copy link
Contributor Author

@jcfr I am working through the 'clazy' qt5->qt6 preparation recommendations.

I was hoping that this could be two separate PR's, but after a few hours trying to separate them, I gave up.

@hjmjohnson hjmjohnson force-pushed the update-Q_OBJECT-clazy branch 5 times, most recently from ff6a9dd to 8dfa920 Compare July 5, 2025 14:23
@hjmjohnson hjmjohnson force-pushed the update-Q_OBJECT-clazy branch from 7f61cb0 to 88fde4f Compare July 5, 2025 16:22
@hjmjohnson hjmjohnson requested a review from pieper July 5, 2025 16:23
@hjmjohnson hjmjohnson force-pushed the update-Q_OBJECT-clazy branch from 0ff3b60 to fcbaed2 Compare July 7, 2025 10:48
@hjmjohnson hjmjohnson requested a review from jamesobutler July 7, 2025 10:48
@hjmjohnson hjmjohnson force-pushed the update-Q_OBJECT-clazy branch from fcbaed2 to b410652 Compare July 7, 2025 12:59
@hjmjohnson hjmjohnson marked this pull request as draft July 7, 2025 13:49
@hjmjohnson
Copy link
Contributor Author

Build issues missed because BUILD_TESTING was off. Need to fix the code that is exercised by tests the same way other fixes were done.

@hjmjohnson hjmjohnson force-pushed the update-Q_OBJECT-clazy branch 4 times, most recently from 07f8a1b to 3fbd3cc Compare July 7, 2025 16:10
@hjmjohnson hjmjohnson marked this pull request as ready for review July 7, 2025 16:32
@hjmjohnson
Copy link
Contributor Author

@jcfr Some next steps for CTK in preparation for Qt6. These are some of the fixes to address issues identified by clazy as recommendations for updating to Qt6.

export CLAZY_CHECKS="qt6-deprecated-api-fixes,qt6-header-fixes,qt6-qhash-signature,qt6-fwd-fixes,missing-qobject-macro"
export CLAZY_EXPORT_FIXES=ON
export CMAKE_EXPORT_COMPILE_COMMANDS=ON
export CMAKE_GENERATOR=Ninja

# use clazy as your compiler
#
cmake -GNinja -S Slicer -B clazySlicer-build -DCMAKE_CXX_COMPILER=clazy
cd clazySlicer-build
cmake --build .

@hjmjohnson hjmjohnson changed the title Update build to use AUTO* cmake build infrastructure to accomodate adding Qt6 Q_OBJECT support COMP: Add AUTO(MOC|UIC|RCC) build. Add missing Q_OBJECT for decendants of QObject Jul 8, 2025
@hjmjohnson hjmjohnson force-pushed the update-Q_OBJECT-clazy branch 2 times, most recently from c45e8de to 49aa264 Compare July 14, 2025 20:59
@hjmjohnson
Copy link
Contributor Author

This depends upon fixing the duplicate symbols associated with PR #1244. Ths PR does not link correctly without PR#1244.

@hjmjohnson hjmjohnson force-pushed the update-Q_OBJECT-clazy branch 2 times, most recently from 1afe9d2 to 8adbb71 Compare July 14, 2025 21:04
The same class is duplicated in two .cpp files.  Duplicate symbols
were created.

Renamed the Widget dialog to be unique
`ctkDICOMMetadataDialog` to `ctkDICOMWidgetMetadataDialog`
Ensure QObject-derived classes properly use the `Q_OBJECT` macro for
meta-object functionality and include corresponding `.moc` files to
support Qt's meta-object compiler.

Add missing Q_OBJECT to complete Qt inheritance

The Q_OBJECT macro is mandatory for any class that:
   • Inherits from QObject
   • Uses signals or slots
   • Declares properties (Q_PROPERTY)
   • Needs qobject_cast, metaObject(), or other Qt RTTI features

Without it:
   • Qt’s meta-object compiler (moc) won’t generate necessary code
   • You may encounter runtime errors or silently broken signals/slots
   • Clazy and Qt's build system may warn or fail

Need to include full class definitions instead of forward definitions.
Replace forward declarations that were common in Qt 5, but are now
discouraged in Qt 6.

Full declarations are required when the Q_OBJECT macro
is included as recommended to respect the Qt inheritance
expectations.
Added `${CMAKE_CURRENT_SOURCE_DIR}/Libs/QtTesting` and
`${CMAKE_CURRENT_BINARY_DIR}/Libs/QtTesting` to include directories
to ensure proper visibility of QtTesting headers.
The AUTO* cmake support removes Qt5 specific wrapping
mechanisms that would be different in Qt6.  Qt6 has
more strict dependance on full class type definitions
that are more easily managed with the AUTO* cmake
builds.

Define UIC search paths in CMake configuration

Simplify and modernize Qt build system integration

Refactor CMake scripts to utilize Qt auto-tools (AUTOMOC, AUTOUIC,
AUTORCC) where applicable, streamline resource and UI handling, and
add support for Qt6. Remove deprecated functions and conditional
processing for obsolete Qt5 versions.

NOTE: This creates a build error that is fixed in the next commit.
```txt
  error: incomplete type 'ctkDICOMSchedulerPrivate' named
         in nested name specifier
```

Remove unnecessary manual wrapping

AUTO* cmake tools preform the wrapping behaviors in the background.
Remove manual wrapping elements.
@hjmjohnson hjmjohnson force-pushed the update-Q_OBJECT-clazy branch from dd13cea to 8a9a958 Compare July 16, 2025 16:38
@hjmjohnson
Copy link
Contributor Author

@pieper Would you mind having another look at this PR?

@jcfr
Copy link
Member

jcfr commented Nov 3, 2025

This pull request is superseded by the following pull request in which only the minimum required changes have been integrated:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants