Skip to content

Commit

Permalink
Fix full screen bar position bug in Qt6.
Browse files Browse the repository at this point in the history
Because wayland is no coordinate system,
borderless forms cannot be dragged and positioned.
qt6 use wayland by default. qt5 use xcb default.
So that prefix 'qputenv("QT_QPA_PLATFORM", "xcb")'
at the beginning of the main function.
  • Loading branch information
KangLin committed Dec 31, 2024
1 parent e7f0d62 commit 95a930b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ jobs:
cmake --install . --config Release --component Plugin --prefix AppDir/usr
# See: https://github.com/linuxdeploy/linuxdeploy-plugin-qt
export QMAKE=$Qt6_DIR/bin/qmake
export EXTRA_PLATFORM_PLUGINS="libqwayland-generic.so;libqxcb.so;libqwayland-egl.so"
export EXTRA_PLATFORM_PLUGINS="libqxcb.so"
${{env.TOOSL_DIR}}/linuxdeploy-`uname -m`.AppImage --appdir=AppDir -v0 \
--deploy-deps-only=AppDir/usr/plugins/Client \
--deploy-deps-only=AppDir/usr/lib/`uname -m`-linux-gnu \
Expand Down
10 changes: 10 additions & 0 deletions App/Client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ static Q_LOGGING_CATEGORY(log, "App.Main")
int main(int argc, char *argv[])
{
int nRet = 0;
#if (defined(Q_OS_LINUX) && !defined(Q_OA_ANDROID) \
&& (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)))
/* 修复使用 Qt6 时,最大化时,工具栏位置错误。
现在很多 linux 用 wayland 作为桌面显示,这样会出现一个问题,
由于没有坐标系统,导致无边框窗体无法拖动和定位(即 QWidge::move 失效)。
(Qt6 开始强制默认优先用 wayland ,Qt5 默认有 xcb 则优先用 xcb),
所以需要在 main 函数最前面加一行 `qputenv("QT_QPA_PLATFORM", "xcb")`;
*/
qputenv("QT_QPA_PLATFORM", "xcb");
#endif
#if (QT_VERSION > QT_VERSION_CHECK(5,6,0)) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
Expand Down
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

### v0.0.31
- Use [RabbitCommon v2.3.2](https://github.com/KangLin/RabbitCommon/releases/tag/v2.3.2)
- Fix full screen bar position bug in Qt6.
Because wayland is no coordinate system,
borderless forms cannot be dragged and positioned.
qt6 use wayland by default. qt5 use xcb default.
So that prefix 'qputenv("QT_QPA_PLATFORM", "xcb")'
at the beginning of the main function.

### v0.0.30
- Client: fix CFrmParameterClient don't save parameters
Expand Down
5 changes: 5 additions & 0 deletions ChangeLog_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

### v0.0.31
- 使用 [RabbitCommon v2.3.2](https://github.com/KangLin/RabbitCommon/releases/tag/v2.3.2)
- 修复使用 Qt6 时,最大化时,工具栏位置错误。
现在很多 linux 用 wayland 作为桌面显示,这样会出现一个问题,
由于没有坐标系统,导致无边框窗体无法拖动和定位(即 QWidge::move 失效)。
(Qt6 开始强制默认优先用 wayland ,Qt5 默认有 xcb 则优先用 xcb),
所以需要在 main 函数最前面加一行 `qputenv("QT_QPA_PLATFORM", "xcb")`;

### v0.0.30
- 客户端: 修复 CFrmParameterClient 不保存参数错误
Expand Down

0 comments on commit 95a930b

Please sign in to comment.