Skip to content

Commit

Permalink
frontend/qt: update to Qt6 on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
benma committed Oct 29, 2024
1 parent 554ed87 commit 0036c11
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ image: Visual Studio 2019
environment:
nodejs_version: "20"
matrix:
- QT: C:\Qt\5.15.2\msvc2019_64
- QT: C:\Qt\6.2\msvc2019_64
# As installed by `choco`
GOROOT: C:\Program Files\Go
GOPATH: C:\gopath\
Expand All @@ -19,7 +19,7 @@ matrix:
fast_finish: true

before_build:
- set PATH=%QT5%\bin;C:\Qt\Tools\QtCreator\bin\;%GOROOT%\bin;C:\gopath\bin\;C:\Qt\5.15.2\msvc2019_64\bin\;C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\MinGW\bin;%PATH%
- set PATH=%QT5%\bin;C:\Qt\Tools\QtCreator\bin\;%GOROOT%\bin;C:\gopath\bin\;C:\Qt\6.2\msvc2019_64\bin\;C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\MinGW\bin;%PATH%
- set MINGW_BIN=/c/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin

build_script:
Expand Down
5 changes: 5 additions & 0 deletions frontends/qt/BitBox.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

QT += core gui
QT += webenginewidgets
win32 {
# For setting 'AlwaysActivate', see.
# See https://forum.qt.io/topic/133694/using-alwaysactivatewindow-to-gain-foreground-in-win10-using-qt6-2/2
QT += gui-private
}

TARGET = BitBox
TEMPLATE = app
Expand Down
12 changes: 12 additions & 0 deletions frontends/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
#include <QMessageBox>
#include <QtGlobal>
#if defined(_WIN32)
#if QT_VERSION_MAJOR >= 6
#include <private/qguiapplication_p.h>
#else
#include <QtPlatformHeaders/QWindowsWindowFunctions>
#endif
#endif

#include <iostream>
#include <set>
Expand Down Expand Up @@ -401,7 +405,15 @@ int main(int argc, char *argv[])
#if defined(_WIN32)
// Allow existing app to be brought to the foreground. See `view->activateWindow()` above.
// Without this, on Windows, only the taskbar entry would light up.
#if QT_VERSION_MAJOR >= 6
// See See https://forum.qt.io/topic/133694/using-alwaysactivatewindow-to-gain-foreground-in-win10-using-qt6-2/2
// Later Qt versions may expose this API again officially. https://www.qt.io/blog/platform-apis-in-qt-6.
if (auto inf = a.nativeInterface<QNativeInterface::Private::QWindowsApplication>()) {
inf->setWindowActivationBehavior(QNativeInterface::Private::QWindowsApplication::AlwaysActivateWindow);
}
#else
QWindowsWindowFunctions::setWindowActivationBehavior(QWindowsWindowFunctions::AlwaysActivateWindow);
#endif
#endif

// Receive and handle an URI sent by a secondary instance (see above).
Expand Down

0 comments on commit 0036c11

Please sign in to comment.