Skip to content

Conversation

@codeling
Copy link
Contributor

@codeling codeling commented Nov 17, 2025

Starting with Qt 6.7 (corrected, was incorrect 6.9), the stateChanged signal in QCheckBox has been deprecated in favor of the checkStateChanged signal; this pull request applies this change also in CTK code (and updates it to the new connection syntax, which can be checked during compile time).

@jcfr
Copy link
Member

jcfr commented Nov 17, 2025

Thanks for the contribution 🙏

Since you are working on this ... do you think you could apply a similar change to all use of the deprecated signal in the codebase?

@codeling
Copy link
Contributor Author

codeling commented Nov 17, 2025

Since you are working on this ... do you think you could apply a similar change to all use of the deprecated signal in the codebase?

I thought I had caught all usages of stateChanged but it looks like I missed one in Libs/DICOM/Widgets/Resources/UI/ctkDICOMAppWidget.ui (though I do not yet know how to best address this one, I cannot use preprocessor defines in .ui files, the connection would probably have to be moved to source instead?). Did you see any other that I missed?

@codeling codeling changed the title BUG: Fix Qt >= 6.9 QCheckBox stateChanged -> checkStateChanged COMP: Fix Qt >= 6.9 QCheckBox stateChanged -> checkStateChanged Nov 24, 2025
@jcfr
Copy link
Member

jcfr commented Nov 24, 2025

re: ui file

I suggest to set the connection in the cpp file instead of the ui file. This should allow to conditionally connect.

@jamesobutler jamesobutler requested review from jcfr and lassoan December 8, 2025 17:18
@codeling codeling changed the title COMP: Fix Qt >= 6.9 QCheckBox stateChanged -> checkStateChanged COMP: Fix Qt >= 6.7 QCheckBox stateChanged -> checkStateChanged Dec 9, 2025
@codeling
Copy link
Contributor Author

codeling commented Dec 9, 2025

EDIT: changed Qt version check to 6.7, since this is the actual version that checkStateChanged was introduced.

Copy link

Copilot AI left a 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 PR updates the CTK codebase to use Qt's new checkStateChanged signal instead of the deprecated stateChanged signal for QCheckBox, with conditional compilation based on Qt version 6.7 or later. The changes also migrate to Qt's new connection syntax (function pointers) for better compile-time type checking.

  • Adds Qt version checks (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) to conditionally use the appropriate signal
  • Migrates from old-style SIGNAL/SLOT macros to new-style function pointer syntax for Qt 6.7+
  • Removes UI file connection in favor of programmatic connection to support version-dependent logic

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
Libs/Widgets/ctkModalityWidget.cpp Adds conditional compilation to use checkStateChanged signal with new connection syntax for Qt 6.7+, while maintaining backward compatibility with stateChanged for older versions
Libs/DICOM/Widgets/ctkDICOMServerNodeWidget2.cpp Updates storage checkbox connection to use checkStateChanged signal with new connection syntax for Qt 6.7+, preserving old-style connection for older versions
Libs/DICOM/Widgets/ctkDICOMAppWidget.cpp Adds version-conditional connection for auto-play checkbox, using checkStateChanged for Qt 6.7+ and stateChanged for older versions, both with new connection syntax
Libs/DICOM/Widgets/Resources/UI/ctkDICOMAppWidget.ui Removes the auto-play checkbox connection from UI file to allow programmatic connection with version-specific signal selection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 270 to 272
connect(d->AutoPlayCheckbox, &QCheckBox::checkStateChanged, this, &ctkDICOMAppWidget::onAutoPlayCheckboxStateChanged);
#else
connect(d->AutoPlayCheckbox, &QCheckBox::stateChanged, this, &ctkDICOMAppWidget::onAutoPlayCheckboxStateChanged);
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation style. The code within the #if/#else blocks uses extra indentation (4 spaces), which is inconsistent with the rest of the file and with the style used in the other modified files (ctkModalityWidget.cpp and ctkDICOMServerNodeWidget2.cpp) where the code is not indented relative to the preprocessor directives. For consistency, remove the extra indentation.

Suggested change
connect(d->AutoPlayCheckbox, &QCheckBox::checkStateChanged, this, &ctkDICOMAppWidget::onAutoPlayCheckboxStateChanged);
#else
connect(d->AutoPlayCheckbox, &QCheckBox::stateChanged, this, &ctkDICOMAppWidget::onAutoPlayCheckboxStateChanged);
connect(d->AutoPlayCheckbox, &QCheckBox::checkStateChanged, this, &ctkDICOMAppWidget::onAutoPlayCheckboxStateChanged);
#else
connect(d->AutoPlayCheckbox, &QCheckBox::stateChanged, this, &ctkDICOMAppWidget::onAutoPlayCheckboxStateChanged);

Copilot uses AI. Check for mistakes.
this->setupUi(q);

this->AnyCheckBox->setTristate(true);
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description states "Starting with Qt 6.9, the stateChanged signal in QCheckBox has been deprecated," but the version check here uses QT_VERSION_CHECK(6, 7, 0). Please verify the correct Qt version where stateChanged was deprecated and checkStateChanged was introduced, and ensure the version check is accurate. If Qt 6.7 is correct, the PR description should be updated to reflect this.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The QCheckBox::checkState exists since 6.7, the 6.9 in the original description is incorrect and was updated.


q->readSettings();

#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description states "Starting with Qt 6.9, the stateChanged signal in QCheckBox has been deprecated," but the version check here uses QT_VERSION_CHECK(6, 7, 0). Please verify the correct Qt version where stateChanged was deprecated and checkStateChanged was introduced, and ensure the version check is accurate. If Qt 6.7 is correct, the PR description should be updated to reflect this.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The QCheckBox::checkState exists since 6.7, the 6.9 in the original description is incorrect and was updated.


d->ThumbnailsWidget->setThumbnailSize(
QSize(d->ThumbnailWidthSlider->value(), d->ThumbnailWidthSlider->value()));

Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description states "Starting with Qt 6.9, the stateChanged signal in QCheckBox has been deprecated," but the version check here uses QT_VERSION_CHECK(6,7,0). Please verify the correct Qt version where stateChanged was deprecated and checkStateChanged was introduced, and ensure the version check is accurate. If Qt 6.7 is correct, the PR description should be updated to reflect this.

Suggested change
// Starting with Qt 6.7, the stateChanged signal in QCheckBox is deprecated in favor of checkStateChanged.

Copilot uses AI. Check for mistakes.
d->ThumbnailsWidget->setThumbnailSize(
QSize(d->ThumbnailWidthSlider->value(), d->ThumbnailWidthSlider->value()));

#if QT_VERSION >= QT_VERSION_CHECK(6,7,0)
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent spacing in QT_VERSION_CHECK macro. This file uses QT_VERSION_CHECK(6,7,0) without spaces after commas, while the other modified files (ctkModalityWidget.cpp and ctkDICOMServerNodeWidget2.cpp) use QT_VERSION_CHECK(6, 7, 0) with spaces. For consistency, use the same spacing convention across all modified files.

Suggested change
#if QT_VERSION >= QT_VERSION_CHECK(6,7,0)
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)

Copilot uses AI. Check for mistakes.
Use the recommended checkStateChanged signal instead of the somewhat ambiguous stateChanged signal in Qt versions where the new signal is available.
@lassoan lassoan force-pushed the Qt6CheckBoxStateChangedDeprecationFix branch from c96fc1e to 3ba6daf Compare December 10, 2025 02:10
Copy link
Member

@lassoan lassoan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good, thank you!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

d->ThumbnailsWidget->setThumbnailSize(
QSize(d->ThumbnailWidthSlider->value(), d->ThumbnailWidthSlider->value()));

#if QT_VERSION >= QT_VERSION_CHECK(6,7,0)
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent spacing in version check. Use QT_VERSION_CHECK(6, 7, 0) with spaces after commas to match the style used in the other files (ctkModalityWidget.cpp and ctkDICOMServerNodeWidget2.cpp).

Suggested change
#if QT_VERSION >= QT_VERSION_CHECK(6,7,0)
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)

Copilot uses AI. Check for mistakes.
#if QT_VERSION >= QT_VERSION_CHECK(6,7,0)
connect(d->AutoPlayCheckbox, &QCheckBox::checkStateChanged, this, &ctkDICOMAppWidget::onAutoPlayCheckboxStateChanged);
#else
connect(d->AutoPlayCheckbox, &QCheckBox::stateChanged, this, &ctkDICOMAppWidget::onAutoPlayCheckboxStateChanged);
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation. The connect statement should use 2 spaces for indentation to match the project style, not 4 spaces.

Suggested change
connect(d->AutoPlayCheckbox, &QCheckBox::stateChanged, this, &ctkDICOMAppWidget::onAutoPlayCheckboxStateChanged);
connect(d->AutoPlayCheckbox, &QCheckBox::stateChanged, this, &ctkDICOMAppWidget::onAutoPlayCheckboxStateChanged);

Copilot uses AI. Check for mistakes.
@lassoan lassoan merged commit a4179cd into commontk:master Dec 10, 2025
10 checks passed
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.

3 participants