Skip to content

Conversation

@hjmjohnson
Copy link
Contributor

@hjmjohnson hjmjohnson commented Jul 8, 2025

The last 2 commits are the new items that need reviewing.

There are the most prominent warnings from clazy.

  • ENH: Update Q_PROPERTIES with CONSTANT specifier for Qt best practices
  • ENH: Add NOTIFY signals for Q_PROPERTIES

@hjmjohnson hjmjohnson marked this pull request as draft July 8, 2025 01:39
@hjmjohnson hjmjohnson changed the title fix NOTIFY warnings COMP: Fix NOTIFY warnings in Q_PROPERTIES Jul 8, 2025
@hjmjohnson
Copy link
Contributor Author

ninja clean; cmake . ; 
ninja > logger 2>&1 ; 
grep PROP logger| grep CTK |fgrep -v CTK-build |sort |uniq -c |sort -nr > XX.err

@hjmjohnson hjmjohnson force-pushed the fix-NOTIFY-warnings branch 2 times, most recently from 6e87200 to 7817ef4 Compare July 8, 2025 20:35
@hjmjohnson hjmjohnson force-pushed the fix-NOTIFY-warnings branch 3 times, most recently from 27053ce to b7bb3c0 Compare July 9, 2025 22:04
@hjmjohnson hjmjohnson marked this pull request as ready for review July 10, 2025 02:23
@hjmjohnson hjmjohnson force-pushed the fix-NOTIFY-warnings branch from b7bb3c0 to 7816c38 Compare July 14, 2025 19:54
@hjmjohnson hjmjohnson marked this pull request as draft July 14, 2025 20:52
@hjmjohnson
Copy link
Contributor Author

I need to build slicer against this DRAFT PR to minimize the number of compiler warnings that originate from CTK. It is a long chain of commits that are being isolated for independant reviewing.

@hjmjohnson hjmjohnson force-pushed the fix-NOTIFY-warnings branch 2 times, most recently from 0c22878 to 5dc84eb Compare July 16, 2025 16:33
@jcfr jcfr force-pushed the fix-NOTIFY-warnings branch from 5dc84eb to b1517c0 Compare November 4, 2025 22:24
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.
•	Requires explicit declaration of the enum in Q_ENUMS(...).
•	Does not support compile-time introspection via QMetaEnum::fromType<T>().
•	Print conversions via qDebug() or QVariant conversions not automatically supported.

•	Replace all Q_ENUMS(...) with Q_ENUM(...) in your QObject classes.
•	Make sure the enum is declared immediately before the Q_ENUM macro.
•	After migration, there is seamless integration into Qt’s meta-object system, better introspection, and compatibility with modern Qt5 (5.5+) and Qt6.
As recommended for Qt best practices

For improved compliance and to address warnings, marked read-only
Q_PROPERTIES as CONSTANT across multiple modules, ensuring adherence to
modern Qt conventions.
Emit change signals and add NOTIFY specifiers to Q_PROPERTIES for
enhanced reactivity and conformance with modern Qt practices.

Recommended changes to address the warning were performed.

```txt
warning: Q_PROPERTY should have either NOTIFY or CONSTANT
[-Wclazy-qproperty-without-notify]
```

Introduced `CTK_SET_CPP_EMIT` macro for setter functionality with signal
emission.

Convert signal parameters to be `const reference`

Refactor signal definitions to use `const` reference types, ensuring
improved performance and adherence to modern Qt coding standards
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.

1 participant