Skip to content

qt, build, ci: add optional Qt 6 support #2798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

CyberTailor
Copy link
Contributor

Introduce USE_QT6 CMake option to build the GUI with Qt 6 instead of Qt 5. Most of porting work was done with the assistance of Clazy and somewhat carefully reading the docs.

No functional changes are required.

Rationale

Qt5 upstream (Qt Company) OSS support ended on 2020-12-081. Since then, bugs are only fixed if reproduced in Qt6 first, then backported. Since then, public availability of commercial 5.15 LTS releases is delayed by 1 year, including repository access for cherry-picking.

The last official LTS release will be this April/May:
https://www.qt.io/blog/qt-5.15-extended-support-for-subscription-license-holders
https://wiki.qt.io/Qt_5.15_Release#Release_Plan

Public availability of this release will be 1 year later, in April/May 2026. There will be no Qt5 releases or bugfixes going forward.

KDE's Qt5PatchCollection has no clear EOL date2, but since most of KDE has moved to Qt 6, it wouldn't last for long. And this work relies on Qt company's upstream commits anyway.

Some distros already stopped accepting new packages that use Qt 5, and began actively cleaning packages with no plans for porting to Qt 6.

Footnotes

  1. https://www.qt.io/blog/qt-offering-changes-2020

  2. https://community.kde.org/Qt5PatchCollection#For_how_long_will_this_be_maintained?

@CyberTailor CyberTailor changed the title Add optional Qt 6 support qt, build, ci: add optional Qt 6 support Mar 25, 2025
@jamescowens jamescowens self-requested a review March 26, 2025 00:52
@div72
Copy link
Member

div72 commented Apr 6, 2025

@jamescowens What are your thoughts on porting this to automake? Upstream is moving to CMake with the soon to be released v29, we might as well move to CMake-only with the next update/mandatory too.

@CyberTailor
Copy link
Contributor Author

Qt 6 has all necessary pkg-config files, so it can be used with autotools. In my opinion, it would be easier to switch from Qt 5 to Qt 6 unconditionally to avoid adding more complexity to the build system.

@CyberTailor
Copy link
Contributor Author

we might as well move to CMake-only with the next update/mandatory too

There is indeed no point in maintaining two build systems, and there should be a roadmap for replacing autotools with CMake to fill the gaps. CD still uses autotools, and it would need to be also ported. For creating installers and packages I've seen CPack being used. Makefile-based "depends" can still be used for the time being, as it's out of build system scope.

@jamescowens
Copy link
Member

I had an offline conversation with @div72 about this. I agree. I think it is time to retire both Qt5 and the autotools build system. Big change, but it is the right move. I am willing to do this for the next mandatory (Natasha) given that we have some time while the consensus-critical code is soaking in testnet.

@jamescowens
Copy link
Member

@CyberTailor Can you rebase this PR to the head of the development branch to clear the merge conflict please?

@ZiggySchulz
Copy link

ZiggySchulz commented Apr 27, 2025

Building this branch on macOS with using Qt 6.9 and CMake version 4.0.1 I get the following error

CMake Error at src/secp256k1/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.

Which I believe is an existing issue. But after increasing the version I get the following deprecation warnings (duplicates removed):

/Users/ziggy/Documents/Dev/Gridcoin/Gridcoin-Research/src/qt/bitcoingui.cpp:316:54: warning: 'operator+' is deprecated: Use operator| instead [-Wdeprecated-declarations]
  316 |     overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
/Users/ziggy/Documents/Dev/Gridcoin/Gridcoin-Research/src/qt/optionsdialog.cpp:91:85: warning: 'nativeCountryName' is deprecated: Use nativeTerritoryName() instead [-Wdeprecated-declarations]
   91 |             ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
/Users/ziggy/Documents/Dev/Gridcoin/Gridcoin-Research/src/qt/sendcoinsdialog.cpp:51:56: warning: 'stateChanged' is deprecated: Use checkStateChanged() instead [-Wdeprecated-declarations]
   51 |     connect(ui->coinControlChangeCheckBox, &QCheckBox::stateChanged, this, &SendCoinsDialog::coinControlChangeChecked);
/Users/ziggy/Documents/Dev/Gridcoin/Gridcoin-Research/src/qt/voting/polltablemodel.cpp:268:5: warning: ignoring return value of function declared with 'nodiscard' attribute: Use QThreadPool::start(Callable&&) if you don't need the returned QFuture [-Wunused-result]
  268 |     QtConcurrent::run([this]() {
/Users/ziggy/Documents/Dev/Gridcoin/Gridcoin-Research/src/qt/bitcoin.cpp:294:36: warning: 'AA_UseHighDpiPixmaps' is deprecated: High-DPI pixmaps are always enabled. This attribute no longer has any effect. [-Wdeprecated-declarations]
  294 |     QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
/Users/ziggy/Documents/Dev/Gridcoin/Gridcoin-Research/src/qt/bitcoin.cpp:394:59: warning: 'location' is deprecated: Use path() [-Wdeprecated-declarations]
  394 |     if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))

All of which seems like easy fixes. An example of how I fixed the warnings on my branch can be seen here:
ZiggySchulz@932a26d

@CyberTailor
Copy link
Contributor Author

Yes, fixes for these deprecation warnings should be applied when Qt 5 support is dropped.

My pull request is rather conservative as I don't know what's on the development team's roadmap and thus try to be careful.

Also I was told that your branch could be rebased on top of mine. Can I do that for you?

@ZiggySchulz
Copy link

Ah of course.

All good for the rebasing, up and rolling based on your code :)

@CyberTailor
Copy link
Contributor Author

I've made a merge commit instead of rebasing, as it was easier. You should be able to pull from my qt6-only branch into your qt6 branch.

https://github.com/CyberTailor/Gridcoin-Research/tree/qt6-only

@ZiggySchulz
Copy link

Looks good thank you. Annoying about the _qs warning. Looks like Ubuntu 22.04 only has 6.2 in its repo so we probably can't justify bumping the version higher than that for a fair while :(

@jamescowens
Copy link
Member

Let's get this rebased on top of development, which now includes the CI fixes and get this finalized. I want to get this merged to ensure we don't drop off the trailing edge on Qt.

When using CMake, disable functionality deprecated before Qt 5.15.
This action is broken with Boost and Qt 6, making it basically useless.
@CyberTailor
Copy link
Contributor Author

Done rebasing

@ZiggySchulz
Copy link

Currently in macOS the application gets called gridcoinreasearch in the menu bar. Adding
MACOSX_BUNDLE_BUNDLE_NAME "Gridcoin Wallet"
or similar to CMake fixes this issue.
Another macOS issue with CMake is the application logo doesn't get set. I've managed to get this going by adding

target_sources(gridcoinresearch PRIVATE
    res/icons/gridcoin.icns
)
...
    MACOSX_BUNDLE_ICON_FILE "gridcoin.icns"
...
set_source_files_properties(res/icons/gridcoin.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

On another side note, which I am unsure if it is related to CMake, my builds don't respond to Command+Q or Gridcoin->Quit so I am having to force quit the app.
Can be addressed elsewhere, otherwise seems to work well :)

@CyberTailor
Copy link
Contributor Author

Currently in macOS the application gets called gridcoinreasearch in the menu bar. Adding MACOSX_BUNDLE_BUNDLE_NAME "Gridcoin Wallet" or similar to CMake fixes this issue. Another macOS issue with CMake is the application logo doesn't get set. I've managed to get this going by adding

target_sources(gridcoinresearch PRIVATE
    res/icons/gridcoin.icns
)
...
    MACOSX_BUNDLE_ICON_FILE "gridcoin.icns"
...
set_source_files_properties(res/icons/gridcoin.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

Gridcoin has a custom Info.plist template, so I changed CMake properties to use it instead of the default template. Check the recently pushed branch, does it display correctly now?

As for packaging, CMake's CPack can build DMG installers as well as other package formats. This will be implemented in follow-up PRs.

@ZiggySchulz
Copy link

Yep, looks good :)

@jamescowens jamescowens requested a review from div72 May 27, 2025 03:08
Copy link
Member

@div72 div72 left a comment

Choose a reason for hiding this comment

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

ACK ccf2059.

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

Successfully merging this pull request may close these issues.

4 participants