Skip to content

Commit dc53f7f

Browse files
committed
Merge #13458: gui: Drop qt4 support
af6ac3b doc: Remove mention of Qt4 from build docs (Wladimir J. van der Laan) 462c71f test: Update travis to not test Qt4 anymore (Wladimir J. van der Laan) 907f73b gui: Remove QT_VERSION fallbacks for Qt < 5 (Wladimir J. van der Laan) bad068a build: Build system changes to support only Qt5 (Wladimir J. van der Laan) Pull request description: Implements #8263. Qt4.x has been EOL since 2015, and at least Gentoo has, or is going to drop support for it. I wouldn't be surprised if other Linux distributions follow. This removes Qt4 detection from the build system, as well as removes all Qt4 fallbacks from the code. Turns out there's more than I expected: this is going to make maintenance of the GUI code, as well as adding new features significantly easier. (I know there's still some references left to qt4 in RPM and Debian build script, but I don't have the knowledge how to fix them) Tree-SHA512: d495924fd4dda6f6566ba44ee96be7cbe62e69ba1ca993b80a8449f78da852b7f1bd3e8200d57cfa1d72233c340eeff4596fb0032ecbddc715d99aea63817d3f
2 parents 5eca4e8 + af6ac3b commit dc53f7f

30 files changed

+110
-344
lines changed

.travis.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ env:
3535
- HOST=i686-pc-linux-gnu PACKAGES="g++-multilib python3-zmq" DEP_OPTS="NO_QT=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++" CONFIG_SHELL="/bin/dash"
3636
# x86_64 Linux (uses qt5 dev package instead of depends Qt to speed up build and avoid timeout)
3737
- HOST=x86_64-unknown-linux-gnu PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools protobuf-compiler libdbus-1-dev libharfbuzz-dev libprotobuf-dev" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1 ALLOW_HOST_PACKAGES=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER"
38-
# Qt4 & system libs
39-
- HOST=x86_64-unknown-linux-gnu PACKAGES="python3-zmq qt4-dev-tools libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev xvfb libqt4-dev" NO_DEPENDS=1 NEED_XVFB=1 RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --enable-glibc-back-compat --enable-reduce-exports --with-gui=qt4 CPPFLAGS=-DDEBUG_LOCKORDER" DISPLAY=:99.0
38+
# x86_64 Linux (Qt5 & system libs)
39+
- HOST=x86_64-unknown-linux-gnu PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev" NO_DEPENDS=1 RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --enable-glibc-back-compat --enable-reduce-exports --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER"
4040
# x86_64 Linux, No wallet
4141
- HOST=x86_64-unknown-linux-gnu PACKAGES="python3" DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
4242
# Cross-Mac
@@ -45,7 +45,7 @@ env:
4545
before_install:
4646
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")
4747
install:
48-
- env | grep -E '^(CCACHE_|WINEDEBUG|DISPLAY|BOOST_TEST_RANDOM|CONFIG_SHELL)' | tee /tmp/env
48+
- env | grep -E '^(CCACHE_|WINEDEBUG|BOOST_TEST_RANDOM|CONFIG_SHELL)' | tee /tmp/env
4949
- if [[ $HOST = *-mingw32 ]]; then DOCKER_ADMIN="--cap-add SYS_ADMIN"; fi
5050
- DOCKER_ID=$(docker run $DOCKER_ADMIN -idt --mount type=bind,src=$TRAVIS_BUILD_DIR,dst=$TRAVIS_BUILD_DIR --mount type=bind,src=$CCACHE_DIR,dst=$CCACHE_DIR -w $TRAVIS_BUILD_DIR --env-file /tmp/env ubuntu:18.04)
5151
- DOCKER_EXEC () { docker exec $DOCKER_ID bash -c "cd $PWD && $*"; }
@@ -58,8 +58,6 @@ before_script:
5858
- if [ -n "$OSX_SDK" -a -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then tar -C depends/SDKs -xf depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi
5959
- if [[ $HOST = *-mingw32 ]]; then DOCKER_EXEC update-alternatives --set $HOST-g++ \$\(which $HOST-g++-posix\); fi
6060
- if [ -z "$NO_DEPENDS" ]; then DOCKER_EXEC CONFIG_SHELL= make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS; fi
61-
# Start xvfb if needed, as documented at https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-a-GUI
62-
- if [ "$NEED_XVFB" = 1 ]; then DOCKER_EXEC /sbin/start-stop-daemon --start --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac; fi
6361
script:
6462
- export TRAVIS_COMMIT_LOG=`git log --format=fuller -1`
6563
- OUTDIR=$BASE_OUTDIR/$TRAVIS_PULL_REQUEST/$TRAVIS_JOB_NUMBER-$HOST

build-aux/m4/bitcoin_qt.m4

Lines changed: 90 additions & 147 deletions
Large diffs are not rendered by default.

configure.ac

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ fi
837837
BITCOIN_QT_INIT
838838

839839
dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
840-
BITCOIN_QT_CONFIGURE([$use_pkgconfig], [qt5])
840+
BITCOIN_QT_CONFIGURE([$use_pkgconfig])
841841

842842
if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench = xnonononono; then
843843
use_boost=no
@@ -1422,7 +1422,6 @@ echo "Options used to compile and link:"
14221422
echo " with wallet = $enable_wallet"
14231423
echo " with gui / qt = $bitcoin_enable_qt"
14241424
if test x$bitcoin_enable_qt != xno; then
1425-
echo " qt version = $bitcoin_qt_got_major_vers"
14261425
echo " with qr = $use_qr"
14271426
fi
14281427
echo " with zmq = $use_zmq"

doc/build-osx.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ If you want to build the disk image with `make deploy` (.dmg / optional), you ne
2424

2525
brew install librsvg
2626

27-
NOTE: Building with Qt4 is still supported, however, could result in a broken UI. Building with Qt5 is recommended.
28-
2927
Berkeley DB
3028
-----------
3129
It is recommended to use Berkeley DB 4.8. If you have to build it yourself,

doc/build-unix.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,13 @@ ZMQ dependencies (provides ZMQ API 4.x):
100100
#### Dependencies for the GUI
101101

102102
If you want to build Bitcoin-Qt, make sure that the required packages for Qt development
103-
are installed. Either Qt 5 or Qt 4 are necessary to build the GUI.
104-
If both Qt 4 and Qt 5 are installed, Qt 5 will be used. Pass `--with-gui=qt4` to configure to choose Qt4.
103+
are installed. Qt 5 is necessary to build the GUI.
105104
To build without GUI pass `--without-gui`.
106105

107-
To build with Qt 5 (recommended) you need the following:
106+
To build with Qt 5 you need the following:
108107

109108
sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
110109

111-
Alternatively, to build with Qt 4 you need the following:
112-
113-
sudo apt-get install libqt4-dev libprotobuf-dev protobuf-compiler
114-
115110
libqrencode (optional) can be installed with:
116111

117112
sudo apt-get install libqrencode-dev
@@ -132,7 +127,7 @@ Optional:
132127

133128
sudo dnf install miniupnpc-devel
134129

135-
To build with Qt 5 (recommended) you need the following:
130+
To build with Qt 5 you need the following:
136131

137132
sudo dnf install qt5-qttools-devel qt5-qtbase-devel protobuf-devel
138133

doc/dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ These are the dependencies currently used by Bitcoin Core. You can find instruct
2323
| protobuf | [2.6.3](https://github.com/google/protobuf/releases) | | No | | |
2424
| Python (tests) | | [3.4](https://www.python.org/downloads) | | | |
2525
| qrencode | [3.4.4](https://fukuchi.org/works/qrencode) | | No | | |
26-
| Qt | [5.7.1](https://download.qt.io/official_releases/qt/) | 4.7+ | No | | |
26+
| Qt | [5.7.1](https://download.qt.io/official_releases/qt/) | 5.x | No | | |
2727
| XCB | | | | | [Yes](https://github.com/bitcoin/bitcoin/blob/master/depends/packages/qt.mk#L94) (Linux only) |
2828
| xkbcommon | | | | | [Yes](https://github.com/bitcoin/bitcoin/blob/master/depends/packages/qt.mk#L93) (Linux only) |
2929
| ZeroMQ | [4.2.3](https://github.com/zeromq/libzmq/releases) | | No | | |

src/qt/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This directory contains the BitcoinQT graphical user interface (GUI). It uses the cross-platform framework [Qt](https://www1.qt.io/developers/).
22

3-
The current precise version for Qt 5 is specified in [qt.mk](/depends/packages/qt.mk). Qt 4 is also supported (see [#8263](https://github.com/bitcoin/bitcoin/issues/8263)).
3+
The current precise version for Qt 5 is specified in [qt.mk](/depends/packages/qt.mk).
44

55
## Compile and run
66

@@ -16,7 +16,7 @@ To run:
1616

1717
### forms
1818

19-
Contains [Designer UI](http://doc.qt.io/qt-5.9/designer-using-a-ui-file.html) files. They are created with [Qt Creator](#using-qt-creator-as-ide), but can be edited using any text editor.
19+
Contains [Designer UI](https://doc.qt.io/qt-5.9/designer-using-a-ui-file.html) files. They are created with [Qt Creator](#using-qt-creator-as-ide), but can be edited using any text editor.
2020

2121
### locale
2222

@@ -36,7 +36,7 @@ Represents the main window of the Bitcoin UI.
3636

3737
### \*model.(h/cpp)
3838

39-
The model. When it has a corresponding controller, it generally inherits from [QAbstractTableModel](http://doc.qt.io/qt-5/qabstracttablemodel.html). Models that are used by controllers as helpers inherit from other Qt classes like [QValidator](http://doc.qt.io/qt-5/qvalidator.html).
39+
The model. When it has a corresponding controller, it generally inherits from [QAbstractTableModel](https://doc.qt.io/qt-5/qabstracttablemodel.html). Models that are used by controllers as helpers inherit from other Qt classes like [QValidator](https://doc.qt.io/qt-5/qvalidator.html).
4040

4141
ClientModel is used by the main application `bitcoingui` and several models like `peertablemodel`.
4242

@@ -46,7 +46,7 @@ A controller. `:NAMEpage.cpp` generally includes `:NAMEmodel.h` and `forms/:NAME
4646

4747
### \*dialog.(h/cpp)
4848

49-
Various dialogs, e.g. to open a URL. Inherit from [QDialog](http://doc.qt.io/qt-4.8/qdialog.html).
49+
Various dialogs, e.g. to open a URL. Inherit from [QDialog](https://doc.qt.io/qt-5/qdialog.html).
5050

5151
### paymentserver.(h/cpp)
5252

src/qt/addressbookpage.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,8 @@ void AddressBookPage::setModel(AddressTableModel *_model)
160160
ui->tableView->sortByColumn(0, Qt::AscendingOrder);
161161

162162
// Set column widths
163-
#if QT_VERSION < 0x050000
164-
ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
165-
ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
166-
#else
167163
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
168164
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
169-
#endif
170165

171166
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
172167
this, SLOT(selectionChanged()));

src/qt/bantablemodel.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ class BanTablePriv
5252
node.getBanned(banMap);
5353

5454
cachedBanlist.clear();
55-
#if QT_VERSION >= 0x040700
5655
cachedBanlist.reserve(banMap.size());
57-
#endif
5856
for (const auto& entry : banMap)
5957
{
6058
CCombinedBan banEntry;

src/qt/bitcoin.cpp

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@
5555

5656
#if defined(QT_STATICPLUGIN)
5757
#include <QtPlugin>
58-
#if QT_VERSION < 0x050000
59-
Q_IMPORT_PLUGIN(qcncodecs)
60-
Q_IMPORT_PLUGIN(qjpcodecs)
61-
Q_IMPORT_PLUGIN(qtwcodecs)
62-
Q_IMPORT_PLUGIN(qkrcodecs)
63-
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
64-
#else
6558
#if QT_VERSION < 0x050400
6659
Q_IMPORT_PLUGIN(AccessibleFactory)
6760
#endif
@@ -73,11 +66,6 @@ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
7366
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
7467
#endif
7568
#endif
76-
#endif
77-
78-
#if QT_VERSION < 0x050000
79-
#include <QTextCodec>
80-
#endif
8169

8270
// Declare meta types used for QMetaObject::invokeMethod
8371
Q_DECLARE_METATYPE(bool*)
@@ -151,16 +139,6 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
151139
}
152140

153141
/* qDebug() message handler --> debug.log */
154-
#if QT_VERSION < 0x050000
155-
void DebugMessageHandler(QtMsgType type, const char *msg)
156-
{
157-
if (type == QtDebugMsg) {
158-
LogPrint(BCLog::QT, "GUI: %s\n", msg);
159-
} else {
160-
LogPrintf("GUI: %s\n", msg);
161-
}
162-
}
163-
#else
164142
void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)
165143
{
166144
Q_UNUSED(context);
@@ -170,7 +148,6 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
170148
LogPrintf("GUI: %s\n", msg.toStdString());
171149
}
172150
}
173-
#endif
174151

175152
/** Class encapsulating Bitcoin Core startup and shutdown.
176153
* Allows running startup and shutdown in a different thread from the UI thread.
@@ -586,12 +563,6 @@ int main(int argc, char *argv[])
586563
// Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
587564

588565
/// 1. Basic Qt initialization (not dependent on parameters or configuration)
589-
#if QT_VERSION < 0x050000
590-
// Internal string conversion is all UTF-8
591-
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
592-
QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
593-
#endif
594-
595566
Q_INIT_RESOURCE(bitcoin);
596567
Q_INIT_RESOURCE(bitcoin_locale);
597568

@@ -722,17 +693,12 @@ int main(int argc, char *argv[])
722693
/// 9. Main GUI initialization
723694
// Install global event filter that makes sure that long tooltips can be word-wrapped
724695
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
725-
#if QT_VERSION < 0x050000
726-
// Install qDebug() message handler to route to debug.log
727-
qInstallMsgHandler(DebugMessageHandler);
728-
#else
729696
#if defined(Q_OS_WIN)
730697
// Install global event filter for processing Windows session related Windows messages (WM_QUERYENDSESSION and WM_ENDSESSION)
731698
qApp->installNativeEventFilter(new WinShutdownMonitor());
732699
#endif
733700
// Install qDebug() message handler to route to debug.log
734701
qInstallMessageHandler(DebugMessageHandler);
735-
#endif
736702
// Allow parameter interaction before we create the options model
737703
app.parameterSetup();
738704
// Load GUI settings from QSettings
@@ -753,7 +719,7 @@ int main(int argc, char *argv[])
753719
// so the GUI thread won't be held up.
754720
if (node->baseInitialize()) {
755721
app.requestInitialize();
756-
#if defined(Q_OS_WIN) && QT_VERSION >= 0x050000
722+
#if defined(Q_OS_WIN)
757723
WinShutdownMonitor::registerShutdownBlockReason(QObject::tr("%1 didn't yet exit safely...").arg(QObject::tr(PACKAGE_NAME)), (HWND)app.getMainWinId());
758724
#endif
759725
app.exec();

0 commit comments

Comments
 (0)