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 24, 2024
1 parent 56e7ba5 commit cae6dd8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
10 changes: 6 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@ image: Visual Studio 2019
environment:
nodejs_version: "20"
matrix:
- QT: C:\Qt\5.15.2\msvc2019_64
# As installed by `choco`
GOROOT: C:\Program Files\Go
- GOROOT: C:\Program Files\Go
GOPATH: C:\gopath\
GOTOOLCHAIN: local
PLATFORM: amd64
COMPILER: msvc
PYTHON: C:\Python312

install:
- ps: Install-Product node $env:nodejs_version
- choco install python --version=3.12.6
- python -m pip install aqtinstall
- aqt install-qt windows desktop 6.2.4 win64_mingw_64 -m qtpositioning qtserialport qtwebchannel qtwebengine
- git submodule update --init --recursive

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=C:\Qt\Tools\QtCreator\bin\;%GOROOT%\bin;C:\gopath\bin\;C:\Qt\6.2.4\mingw_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 cae6dd8

Please sign in to comment.