Skip to content

Commit 6d42149

Browse files
committed
cmake: Require Qt 6 to build GUI
1 parent 930b237 commit 6d42149

File tree

12 files changed

+79
-53
lines changed

12 files changed

+79
-53
lines changed

.github/ISSUE_TEMPLATE/good_first_issue.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ body:
2828
id: useful-skills
2929
attributes:
3030
label: Useful Skills
31-
description: For example, “`std::thread`”, “Qt5 GUI and async GUI design” or “basic understanding of Bitcoin mining and the Bitcoin Core RPC interface”.
31+
description: For example, “`std::thread`”, “Qt6 GUI and async GUI design” or “basic understanding of Bitcoin mining and the Bitcoin Core RPC interface”.
3232
value: |
3333
* Compiling Bitcoin Core from source
3434
* Running the C++ unit tests and the Python functional tests

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ if(BUILD_GUI)
174174
if(BUILD_GUI_TESTS)
175175
list(APPEND qt_components Test)
176176
endif()
177-
find_package(Qt 5.11.3 MODULE REQUIRED
177+
find_package(Qt 6.2 MODULE REQUIRED
178178
COMPONENTS ${qt_components}
179179
)
180180
unset(qt_components)

cmake/module/FindQt.cmake

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,13 @@ if(CMAKE_HOST_APPLE)
2727
endif()
2828
endif()
2929

30-
# Save CMAKE_FIND_ROOT_PATH_MODE_LIBRARY state.
31-
unset(_qt_find_root_path_mode_library_saved)
32-
if(DEFINED CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
33-
set(_qt_find_root_path_mode_library_saved ${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY})
34-
endif()
35-
36-
# The Qt config files internally use find_library() calls for all
37-
# dependencies to ensure their availability. In turn, the find_library()
38-
# inspects the well-known locations on the file system; therefore, it must
39-
# be able to find platform-specific system libraries, for example:
40-
# /usr/x86_64-w64-mingw32/lib/libm.a or /usr/arm-linux-gnueabihf/lib/libm.a.
41-
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
42-
4330
find_package(Qt${Qt_FIND_VERSION_MAJOR} ${Qt_FIND_VERSION}
4431
COMPONENTS ${Qt_FIND_COMPONENTS}
4532
HINTS ${_qt_homebrew_prefix}
4633
PATH_SUFFIXES Qt${Qt_FIND_VERSION_MAJOR} # Required on OpenBSD systems.
4734
)
4835
unset(_qt_homebrew_prefix)
4936

50-
# Restore CMAKE_FIND_ROOT_PATH_MODE_LIBRARY state.
51-
if(DEFINED _qt_find_root_path_mode_library_saved)
52-
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ${_qt_find_root_path_mode_library_saved})
53-
unset(_qt_find_root_path_mode_library_saved)
54-
else()
55-
unset(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
56-
endif()
57-
5837
include(FindPackageHandleStandardArgs)
5938
find_package_handle_standard_args(Qt
6039
REQUIRED_VARS Qt${Qt_FIND_VERSION_MAJOR}_DIR

doc/build-freebsd.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ sh/bash: export BDB_PREFIX=[path displayed above]
6262
```
6363

6464
#### GUI Dependencies
65-
###### Qt5
65+
###### Qt6
6666

6767
Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install
6868
the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
6969

7070
```bash
71-
pkg install qt5-buildtools qt5-core qt5-gui qt5-linguisttools qt5-testlib qt5-widgets
71+
pkg install qt6-buildtools qt6-core qt6-gui qt6-linguisttools qt6-testlib qt6-widgets
7272
```
7373

7474
###### libqrencode

doc/build-netbsd.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ pkgin install db4
6464
```
6565

6666
#### GUI Dependencies
67-
###### Qt5
67+
###### Qt6
6868

6969
Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install
7070
the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
7171

7272
```bash
73-
pkgin install qt5-qtbase qt5-qttools
73+
pkgin install qt6-qtbase qt6-qttools
7474
```
7575

7676
###### libqrencode

doc/build-openbsd.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ export BDB_PREFIX="[path displayed above]"
5656
```
5757

5858
#### GUI Dependencies
59-
###### Qt5
59+
###### Qt6
6060

6161
Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install
6262
the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
6363

6464
```bash
65-
pkg_add qtbase qttools
65+
pkg_add qt6-qtbase qt6-qttools
6666
```
6767

6868
###### libqrencode
@@ -100,7 +100,7 @@ pkg_add python py3-zmq # Select the newest version of the python package if nec
100100
There are many ways to configure Bitcoin Core, here are a few common examples:
101101

102102
##### Descriptor Wallet and GUI:
103-
This enables descriptor wallet support and the GUI, assuming SQLite and Qt 5 are installed.
103+
This enables descriptor wallet support and the GUI, assuming SQLite and Qt 6 are installed.
104104

105105
```bash
106106
cmake -B build -DBUILD_GUI=ON

doc/build-osx.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,9 @@ Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compi
9292
Qt, libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
9393

9494
``` bash
95-
brew install qt@5
95+
brew install qt@6
9696
```
9797

98-
Note: Building may fail if Qt 6 is installed (`qt` or `qt@6`)
99-
10098
Note: Building with Qt binaries downloaded from the Qt website is not officially supported.
10199
See the notes in [#7714](https://github.com/bitcoin/bitcoin/issues/7714).
102100

doc/build-unix.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ GUI dependencies:
7373
Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install
7474
the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
7575

76-
sudo apt-get install qtbase5-dev qttools5-dev qttools5-dev-tools
76+
sudo apt-get install qt6-base-dev qt6-tools-dev qt6-l10n-tools
77+
78+
For Qt 6.5 and later, the `libxcb-cursor0` package must be installed at runtime.
7779

7880
Additionally, to support Wayland protocol for modern desktop environments:
7981

80-
sudo apt install qtwayland5
82+
sudo apt install qt6-wayland
8183

8284
The GUI will be able to encode addresses in QR codes unless this feature is explicitly disabled. To install libqrencode, run:
8385

@@ -121,11 +123,13 @@ GUI dependencies:
121123
Bitcoin Core includes a GUI built with the cross-platform Qt Framework. To compile the GUI, we need to install
122124
the necessary parts of Qt, the libqrencode and pass `-DBUILD_GUI=ON`. Skip if you don't intend to use the GUI.
123125

124-
sudo dnf install qt5-qttools-devel qt5-qtbase-devel
126+
sudo dnf install qt6-qtbase-devel qt6-qttools-devel
127+
128+
For Qt 6.5 and later, the `xcb-util-cursor` package must be installed at runtime.
125129

126130
Additionally, to support Wayland protocol for modern desktop environments:
127131

128-
sudo dnf install qt5-qtwayland
132+
sudo dnf install qt6-qtwayland
129133

130134
The GUI will be able to encode addresses in QR codes unless this feature is explicitly disabled. To install libqrencode, run:
131135

src/qt/CMakeLists.txt

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,35 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
1111
string(APPEND CMAKE_OBJCXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}")
1212
endif()
1313

14-
get_target_property(qt_lib_type Qt5::Core TYPE)
14+
get_target_property(qt_lib_type Qt6::Core TYPE)
1515

1616
function(import_plugins target)
1717
if(qt_lib_type STREQUAL "STATIC_LIBRARY")
18-
set(plugins Qt5::QMinimalIntegrationPlugin)
18+
set(plugins Qt6::QMinimalIntegrationPlugin)
1919
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
20-
list(APPEND plugins Qt5::QXcbIntegrationPlugin)
20+
list(APPEND plugins Qt6::QXcbIntegrationPlugin)
2121
elseif(WIN32)
22-
list(APPEND plugins Qt5::QWindowsIntegrationPlugin Qt5::QWindowsVistaStylePlugin)
22+
list(APPEND plugins Qt6::QWindowsIntegrationPlugin Qt6::QWindowsVistaStylePlugin)
2323
elseif(APPLE)
24-
list(APPEND plugins Qt5::QCocoaIntegrationPlugin Qt5::QMacStylePlugin)
24+
list(APPEND plugins Qt6::QCocoaIntegrationPlugin Qt6::QMacStylePlugin)
2525
endif()
26-
qt5_import_plugins(${target}
26+
qt6_import_plugins(${target}
2727
INCLUDE ${plugins}
28-
EXCLUDE_BY_TYPE imageformats iconengines
28+
EXCLUDE_BY_TYPE
29+
accessiblebridge
30+
platforms
31+
platforms_darwin
32+
xcbglintegrations
33+
platformthemes
34+
platforminputcontexts
35+
generic
36+
iconengines
37+
imageformats
38+
egldeviceintegrations
39+
styles
40+
networkaccess
41+
networkinformation
42+
tls
2943
)
3044
endif()
3145
endfunction()
@@ -45,7 +59,7 @@ set(CMAKE_AUTOUIC_SEARCH_PATHS forms)
4559
# to https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/main/update-translations.py
4660
file(GLOB ts_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} locale/*.ts)
4761
set_source_files_properties(${ts_files} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/locale)
48-
qt5_add_translation(qm_files ${ts_files})
62+
qt6_add_translation(qm_files ${ts_files})
4963

5064
configure_file(bitcoin_locale.qrc bitcoin_locale.qrc USE_SOURCE_PERMISSIONS COPYONLY)
5165

@@ -128,7 +142,7 @@ set_property(SOURCE macnotificationhandler.mm
128142
)
129143
target_link_libraries(bitcoinqt
130144
PUBLIC
131-
Qt5::Widgets
145+
Qt6::Widgets
132146
PRIVATE
133147
core_interface
134148
bitcoin_cli
@@ -206,19 +220,33 @@ if(ENABLE_WALLET)
206220
target_link_libraries(bitcoinqt
207221
PRIVATE
208222
bitcoin_wallet
209-
Qt5::Network
223+
Qt6::Network
210224
)
211225
endif()
212226

213227
if(WITH_DBUS)
214-
target_link_libraries(bitcoinqt PRIVATE Qt5::DBus)
228+
target_link_libraries(bitcoinqt PRIVATE Qt6::DBus)
215229
endif()
216230

217231
if(qt_lib_type STREQUAL "STATIC_LIBRARY")
218232
# We want to define static plugins to link ourselves, thus preventing
219233
# automatic linking against a "sane" set of default static plugins.
220-
qt5_import_plugins(bitcoinqt
221-
EXCLUDE_BY_TYPE bearer iconengines imageformats platforms styles
234+
qt6_import_plugins(bitcoinqt
235+
EXCLUDE_BY_TYPE
236+
accessiblebridge
237+
platforms
238+
platforms_darwin
239+
xcbglintegrations
240+
platformthemes
241+
platforminputcontexts
242+
generic
243+
iconengines
244+
imageformats
245+
egldeviceintegrations
246+
styles
247+
networkaccess
248+
networkinformation
249+
tls
222250
)
223251
endif()
224252

@@ -321,8 +349,8 @@ else()
321349
file(GLOB ui_files ${CMAKE_CURRENT_SOURCE_DIR}/forms/*.ui)
322350
add_custom_target(translate
323351
COMMAND ${CMAKE_COMMAND} -E env XGETTEXT=${XGETTEXT_EXECUTABLE} COPYRIGHT_HOLDERS=${COPYRIGHT_HOLDERS} ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/share/qt/extract_strings_qt.py ${translatable_sources}
324-
COMMAND Qt5::lupdate -no-obsolete -I ${PROJECT_SOURCE_DIR}/src -locations relative ${CMAKE_CURRENT_SOURCE_DIR}/bitcoinstrings.cpp ${ui_files} ${qt_translatable_sources} -ts ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.ts
325-
COMMAND Qt5::lconvert -drop-translations -o ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.xlf -i ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.ts
352+
COMMAND Qt6::lupdate -no-obsolete -I ${PROJECT_SOURCE_DIR}/src -locations relative ${CMAKE_CURRENT_SOURCE_DIR}/bitcoinstrings.cpp ${ui_files} ${qt_translatable_sources} -ts ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.ts
353+
COMMAND Qt6::lconvert -drop-translations -o ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.xlf -i ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.ts
326354
COMMAND ${SED_EXECUTABLE} -i.old -e "s|source-language=\"en\" target-language=\"en\"|source-language=\"en\"|" -e "/<target xml:space=\"preserve\"><\\/target>/d" ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.xlf
327355
COMMAND ${CMAKE_COMMAND} -E rm ${CMAKE_CURRENT_SOURCE_DIR}/locale/bitcoin_en.xlf.old
328356
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src

src/qt/sendcoinsdialog.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *p
8888

8989
// Coin Control
9090
connect(ui->pushButtonCoinControl, &QPushButton::clicked, this, &SendCoinsDialog::coinControlButtonClicked);
91+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
92+
connect(ui->checkBoxCoinControlChange, &QCheckBox::checkStateChanged, this, &SendCoinsDialog::coinControlChangeChecked);
93+
#else
9194
connect(ui->checkBoxCoinControlChange, &QCheckBox::stateChanged, this, &SendCoinsDialog::coinControlChangeChecked);
95+
#endif
9296
connect(ui->lineEditCoinControlChange, &QValidatedLineEdit::textEdited, this, &SendCoinsDialog::coinControlChangeEdited);
9397

9498
// Coin Control: clipboard actions
@@ -183,8 +187,13 @@ void SendCoinsDialog::setModel(WalletModel *_model)
183187
#endif
184188

185189
connect(ui->customFee, &BitcoinAmountField::valueChanged, this, &SendCoinsDialog::coinControlUpdateLabels);
190+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
191+
connect(ui->optInRBF, &QCheckBox::checkStateChanged, this, &SendCoinsDialog::updateSmartFeeLabel);
192+
connect(ui->optInRBF, &QCheckBox::checkStateChanged, this, &SendCoinsDialog::coinControlUpdateLabels);
193+
#else
186194
connect(ui->optInRBF, &QCheckBox::stateChanged, this, &SendCoinsDialog::updateSmartFeeLabel);
187195
connect(ui->optInRBF, &QCheckBox::stateChanged, this, &SendCoinsDialog::coinControlUpdateLabels);
196+
#endif
188197
CAmount requiredFee = model->wallet().getRequiredFee(1000);
189198
ui->customFee->SetMinValue(requiredFee);
190199
if (ui->customFee->value() < requiredFee) {
@@ -944,7 +953,11 @@ void SendCoinsDialog::coinControlButtonClicked()
944953
}
945954

946955
// Coin Control: checkbox custom change address
956+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
957+
void SendCoinsDialog::coinControlChangeChecked(Qt::CheckState state)
958+
#else
947959
void SendCoinsDialog::coinControlChangeChecked(int state)
960+
#endif
948961
{
949962
if (state == Qt::Unchecked)
950963
{

0 commit comments

Comments
 (0)