Skip to content

Conversation

@jcfr
Copy link
Member

@jcfr jcfr commented Nov 8, 2025

This PR updates several CTK components to improve compatibility across Qt 5.15 and Qt 6.x and to address API changes and deprecations introduced in recent Qt 6 releases:

  • Resolve or prevent deprecation warnings with Qt 6.4–6.6.
  • Maintain full compatibility with Qt 5.15.
  • Prepare CTK for smoother adoption of newer Qt 6 versions without behavioral regressions.

Changes

  • ctkDICOMTester

    • Use QByteArray::size() instead of the deprecated parameter-less count() (Qt 6.4).
  • ctkBasePopupWidget / ctkPopupWidget

    • For QT_VERSION >= 6.5.0, replace deprecated QApplication::setActiveWindow() with activateWindow() on the appropriate widget.
    • Keep QApplication::setActiveWindow() for Qt 5.x / Qt < 6.5 to preserve existing behavior.
  • ctkLanguageComboBox

    • For QT_VERSION >= 6.6.0, use QLocale::territoryToString(locale.territory()) instead of deprecated QLocale::countryToString(locale.country()).
    • Retain the country-based variant for Qt 5.x and earlier Qt 6 versions.
  • ctkQImageView

    • For QT_VERSION >= 6.6.0, use QColor::fromString() for named colors instead of deprecated QColor::setNamedColor().
    • Fallback to setNamedColor() on older Qt versions.
  • ctkTestApplication

    • Construct QMouseEvent with both local and explicit global positions (QCursor::pos()), aligning with modern Qt 5/6 constructors and avoiding deprecated usage.
  • ctkMTDataParser

    • For QT_VERSION >= 6.0.0, use QStringView when reading element and attribute names from QXmlStreamReader/QXmlStreamAttributes, in line with Qt 6 XML APIs.
    • Keep QStringRef for Qt 5.x to maintain dual-build compatibility.

- ctkDICOMTester:
  - Use QByteArray::size() instead of the deprecated parameter-less count()
    (deprecated in Qt 6.4) when checking process output.

- ctkBasePopupWidget / ctkPopupWidget:
  - For Qt >= 6.5, replace deprecated QApplication::setActiveWindow()
    with activateWindow() on the relevant widget, as recommended by Qt.
  - Keep QApplication::setActiveWindow() for Qt 5.x / Qt < 6.5 to preserve
    existing behavior.

- ctkLanguageComboBox:
  - For Qt >= 6.6, use QLocale::territoryToString(locale.territory()) instead
    of deprecated QLocale::countryToString(locale.country()).
  - Retain the country-based code path for Qt 5.x and earlier Qt 6 versions.

- ctkQImageView:
  - For Qt >= 6.6, use QColor::fromString() for named colors instead of
    deprecated QColor::setNamedColor().
  - Use setNamedColor() on older Qt versions for compatibility.

- ctkTestApplication:
  - Construct QMouseEvent with both local position and explicit global
    position (QCursor::pos()), matching modern QMouseEvent constructors in
    Qt 5 and Qt 6.

- ctkMTDataParser:
  - For Qt >= 6.0, use QStringView when reading element/attribute names from
    QXmlStreamReader/QXmlStreamAttributes, aligning with Qt 6 XML APIs.
  - For Qt 5.x, keep using QStringRef, ensuring dual-build compatibility.

Co-authored-by: Stefan Dinkelacker <s.dinkelacker@dkfz-heidelberg.de>
@jcfr jcfr merged commit 7f8cb65 into commontk:master Nov 8, 2025
3 checks passed
@jcfr jcfr deleted the qt6-compat-widgets-parser branch November 8, 2025 23:26
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