Coder Social home page Coder Social logo

stdware / qwindowkit Goto Github PK

View Code? Open in Web Editor NEW
469.0 17.0 70.0 2.06 MB

Cross-platform frameless window framework for Qt. Support Windows, macOS, Linux.

License: Apache License 2.0

CMake 5.70% C++ 84.58% C 0.26% Objective-C++ 9.47%
qt windows cpp cross-platform dwm frameless frameless-helper frameless-window mac win32

qwindowkit's Introduction

QWindowKit

Cross-platform window customization framework for Qt Widgets and Qt Quick.

This project inherited most of wangwenx190 FramelessHelper implementation, with a complete refactoring and upgrading of the architecture.

Feature requests are welcome.

Join with Us 🚩

You can join our Discord channel. You can share your findings, thoughts and ideas on improving / implementing FramelessHelper functionalities on more platforms and apps!

Supported Platforms

  • Microsoft Windows
  • Apple macOS (11+)
  • GNU/Linux

Features

  • Full support of Windows 11 Snap Layout
  • Better workaround to handle Windows 10 top border issue
  • Support Mac system buttons geometry customization
  • Simpler APIs, more detailed documentations and comments

Gallery

Windows 11 (With Snap Layout)

image

Windows 10 (And 7, Vista)

image

macOS & Linux

macOS Linux (Ubuntu 20.04)
image image

Requirements

Component Requirement Details
Qt >=5.12 Core, Gui, Widgets, Quick
Compiler >=C++17 MSVC 2019, GCC, Clang
CMake >=3.19 >=3.20 is recommended

Please read Vulnerabilities carefully to acquire detailed requirements.

Tested Compilers

  • Windows
    • MSVC: 2019, 2022
    • MinGW (GCC): 13.2.0
  • macOS
    • Clang 14.0.3
  • Ubuntu
    • GCC: 9.4.0

Dependencies

Integrate

Build & Install

git clone --recursive https://github.com/stdware/qwindowkit
cd qwindowkit

cmake -B build -S . \
  -Dqmsetup_DIR=<dir> \ # Optional
  -DCMAKE_INSTALL_PREFIX=/path/install \
  -G "Ninja Multi-Config"

cmake --build build --target install --config Debug
cmake --build build --target install --config Release

You can also include this directory as a subproject if you choose CMake as your build system.

For other build systems, you need to install with CMake first and include the corresponding configuration files in your project.

Import

CMake Project

cmake -B build -DQWindowKit_DIR=/path/install/lib/cmake/QWindowKit
find_package(QWindowKit COMPONENTS Core Widgets Quick REQUIRED)
target_link_libraries(widgets_app PUBLIC QWindowKit::Widgets)
target_link_libraries(quick_app PUBLIC QWindowKit::Quick)

QMake Project

# WidgetsApp.pro
include("/path/install/share/QWindowKit/qmake/QWKWidgets.pri")

# QuickApp.pro
include("/path/install/share/QWindowKit/qmake/QWKQuick.pri")

Visual Studio Project

See Visual Studio Guide for detailed usages.

Quick Start

Qt Widgets Application

Initialization

The following initialization should be done before any widget constructs.

#include <QtWidgets/QApplication>

int main(int argc, char *argv[])
{
    QGuiApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings)
    
    // ...
}

Setup Window Agent

First, setup WidgetWindowAgent for your top QWidget instance. (Each window needs its own agent.)

#include <QWKWidgets/widgetwindowagent.h>

MyWidget::MyWidget(QWidget *parent) {
    // ...
    auto agent = new QWK::WidgetWindowAgent(this);
    agent->setup(this);
    // ...
}

If you don't want to derive a new widget class or change the constructor, you can initialize the agent after the window constructs.

auto w = new MyWidget();
auto agent = new QWK::WidgetWindowAgent(w);
agent->setup(w);

You should call QWK::WidgetWindowAgent::setup() as early as possible, especially when you need to set the size constrains. QWindowKit will change some Qt internal data which will affect how Qt calculates the window size, and thus you need to let QWindowKit initialize at the very beginning.

Construct Title bar

Then, construct your title bar widget, without which the window lacks the basic interaction feature, and it's better to put it into the window's layout.

You can use the WindowBar provided by WidgetFrame in the examples as the container of your title bar components.

Let WidgetWindowAgent know which widget the title bar is.

agent->setTitleBar(myTitleBar);

Next, set system button hints to let WidgetWindowAgent know the role of the child widgets, which is important for the Snap Layout to work.

agent->setSystemButton(QWK::WindowAgentBase::WindowIcon, myTitleBar->iconButton());
agent->setSystemButton(QWK::WindowAgentBase::Minimize, myTitleBar->minButton());
agent->setSystemButton(QWK::WindowAgentBase::Maximize, myTitleBar->maxButton());
agent->setSystemButton(QWK::WindowAgentBase::Close, myTitleBar->closeButton());

Doing this does not mean that these buttons' click events are automatically associated with window actions, you still need to manually connect the signals and slots to emulate the native window behaviors.

On macOS, this step can be skipped because it is better to use the buttons provided by the system.

Last but not least, set hit-test visible hint to let WidgetWindowAgent know which widgets are willing to receive mouse events.

agent->setHitTestVisible(myTitleBar->menuBar(), true);

The rest region within the title bar will be regarded as the draggable area for the user to move the window, and thus any QWidgets inside it will not receive any user interaction events such as mouse events/focus events/etc anymore, but you can still send/post such events to these widgets manually, either through Qt API or system API.

  • If you want to disable window maximization, you can remove the Qt::WindowMaximizeButtonHint flag from the window.

Qt Quick Application

Initialization

Make sure you have registered QWindowKit into QtQuick:

#include <QWKQuick/qwkquickglobal.h>

int main(int argc, char *argv[])
{
    // ...
    QQmlApplicationEngine engine;
    // ...
    QWK::registerTypes(&engine);
    // ...
}

Setup Window Components

Then you can use QWindowKit data types and classes by importing its URI:

import QtQuick 2.15
import QtQuick.Window 2.15
import QWindowKit 1.0

Window {
    id: window
    visible: false // We hide it first, so we can move the window to our desired position silently.
    Component.onCompleted: {
        windowAgent.setup(window)
        window.visible = true
    }
    WindowAgent {
        id: windowAgent
        // ...
    }
}

You can omit the version number or use "auto" instead of "1.0" for the module URI if you are using Qt6.

As we just mentioned above, if you are going to set the size constrains, please do it after windowAgent.setup() is called.

Learn More

See examples for more demo use cases. The examples have no High DPI support.

Vulnerabilities

Qt Version

  • To achieve better frameless functionality, QWindowKit depends heavily on Qt's internal implementation. However, there are many differences in different versions of Qt, and earlier versions of Qt5 and Qt6 have many bugs which make it extremely difficult for QWindowKit to workaround without changing the Qt source code.
  • And also due to limited manpower, although QWindowKit can be successfully compiled on Qt 5.12 or later, it can hardly work perfectly on all Qt versions.
  • Therefore, the following Qt version ranges are recommended, if there are any exceptions with QWindowKit in your application, make sure the Qt version you use is in the ranges before raising the issue.
    • Qt 5: 5.15.2 or higher
    • Qt 6: 6.6.2 or higher (the newer, the better)

Hot Switch

  • Once you have made the window frameless, it will not be able to switch back to the system frame again unless you destroy your window and recreate it with different settings.

Native Child Widget

  • There must not be any internal child widget with Qt::WA_NativeWindow property enabled, otherwise the native features and display may be abnormal. Therefore, do not set any widget that has called QWidget::winId() or QWidget::setAttribute(Qt::WA_NativeWindow) as a descendant of a frameless window.
    • If you really need to move widgets between different windows, make sure that the widget is not a top-level window and wrap it with a frameless container window.

Size Constrains

  • If you want to disable window resizing, you can set a fixed size, which is officially supported by QWindowKit. If you use other special means to achieve this, QWK doesn't guarantee everything can still be fully functional.
  • If you set a maximized width or height, the window should not be maximized because you cannot get the correct window size through Qt APIs. You may workaround this by using system APIs such as GetWindowRect or GetClientRect. The root cause lies deep in Qt QPA implementations and currently we don't know how to fix it without modifying Qt itself.

Windows 10

  • Due to the inherent defects in the Windows 10 window system, the top border will disappear when the system title bar is removed. We have filtered Qt's event and perfectly reshown the system top border, thanks to the implementation of Windows Terminal for our reference. However, this workaround only works with QtWidgets and QtQuick (only when rendering through D3D) applications.

  • In QtQuick applications that use OpenGL or other rendering backends, we use Qt's painting system to emulate this border. But since Windows 10 system border is translucent, the difference from the system border is more noticeable in a dark background.

TODO

  • Fix mouse cursor mapping issues
  • More documentations
  • When do we support Linux native features?

Special Thanks

License

QWindowKit is licensed under the Apache 2.0 License.

qwindowkit's People

Contributors

arabaku avatar jacobmuchow avatar mentalfl0w avatar mourinaruto avatar sinestriker avatar wangpengzhan avatar wangwenx190 avatar zhuzichu520 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qwindowkit's Issues

bug

大佬无边框窗口设置Qt::WindowStaysOnTopHint表现不正常

18px border between client area and right window edge

image

Platform: seems to only occur on Windows 10 (22H2-19045.3803) and with ENABLE_WINDOWS_SYSTEM_BORDERS off
Steps to reproduce:

  • I get it on application start with built-in and minimal examples

Note: resizing the app will correct the sizing issue, moving it again will reintroduce it.

Accepting the WM_MOVE event in WindowsNativeEventFilter::nativeEventFilter seems to prevent this from occurring, but I have no idea why or what side effects it introduces.

在Mac上, 修改标题栏高度以及三个系统按钮的位置

1、修改标题栏高度:
在创建标题栏时,设置固定高度即可
windowBar->setFixedHeight(40);
2、修改三个系统按钮位置:

windowAgent->setSystemButtonAreaCallback([](const QSize &size) {
        static constexpr const int width = 75;
        return QRect(QPoint(size.width() - width, 0), QSize(width, size.height())); 
    });

针对这段代码,我改为return QRect(QPoint(size.width() - width, 10), QSize(width, size.height())); y向偏移了,但是无效。
是的还有其他需要设置?

编译报错

1 QtCreator编译,使用msvc模式编译,没有问题

2 QtCreator编译,使用mingw编译,一堆错误(Qt5.15.2版本)

  • 错误1 查看提示查看日志文件,没有看懂,错误类型是什么

1

这是提示的日志文件
qmsetup_build-Release.log

  • 错误2 所有qm开头的cmake指令都不识别
    2

Window content extends too far towards the bottom/right

OS: Windows 11
Qt: 6.5.3
UI Framework: QML, Quick
Build command: cmake -B build -DCMAKE_INSTALL_PREFIX=[hidden] -G "Ninja Multi-Config" -DQT_DIR=[hidden] -DQWINDOWKIT_BUILD_QUICK=ON -DQWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS=OFF

When resizing the Window using the top/left edges part of the bottom client area extends to far into the bottom, resulting in a part being hidden. This also happens when moving the window using the title bar. When starting the application using the suggested method, the window starts in this broken state. Using the bottom/right edges to resize fixes this problem.

EDIT: While the window is maximized the right side is also affected, part of the clientarea extends too far towards the right and is hidden.

I made an example app demonstrating this. The numbers 1-20 should be fully visible, but as you can see even the 19 is only half visible.

After top/left resize, moving the window:
image

After bottom/right resize:
image

qmsetup需要c++20版本支持

你好,我尝试用qt5.14msvc2017编译时发现如下问题:

1、“starts_with”: 不是string的成员
qmsetup需要c++20版本支持starts_with是cpp20才加入的

qwindowkit\qmsetup\src\corecmd\main.cpp(229): error C2039: “starts_with”: 不是“std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>”的成员

image

2、“max”: 不是“std”的成员

qwindowkit\qmsetup\src\syscmdline\src\helplayout.cpp(60): error C2039: “max”: 不是“std”的成员
qwindowkit\qmsetup\src\syscmdline\src\parseresult.cpp(179): error C2039: “max”: 不是“std”的成员

helplayout.cppparseresult.cpp加上algorithm头文件即可#include <algorithm>

QWKExample_MainWindow.exe程序在双屏之前切换时,分辨率越来越小问题

在Windows 11系统下组建双屏扩展模式,1号屏幕分辨率为25601600,2号屏幕分辨率为19201080,在任意屏幕下启动QWKExample_MainWindow.exe后,两个屏幕间用鼠标来回拖动(拖动完成时,需要释放鼠标后,再重新拖动),软件界面的纵向分辨率会变得越来越小,直至纵向分辨率达到最小。
snapshort

编译报错

环境: win11 Qt5.12.2 MSVC2017

编译报错:
windowagentbase.cpp.obj : error LNK2019: 无法解析的外部符号 "public: __cdecl QWK::QtWindowContext::QtWindowContext(void)" (??0QtWindowContext@QWK@@qeaa@XZ),该符号在函数 "public: virtual class QWK::AbstractWindowContext * __cdecl QWK::WindowAgentBasePrivate::createContext(void)const " (?createContext@WindowAgentBasePrivate@QWK@@UEBAPEAVAbstractWindowContext@2@XZ) 中被引用
out-amd64-Release\bin\QWKCore.dll : fatal error LNK1120: 1 个无法解析的外部命令

[功能] 增加默认窗口标题栏

当前 WidgetWindowAgent 仅仅只是一个代理。它没有默认的窗口标题栏。如果用来修改原来的代码。工程量很大。

建议增加默认标题栏。它的要求如下:

  • 系统菜单:如果原窗口是 QMainWindow ,默认使用 QMainWinodw 的系统菜单。
  • 窗口图标:与原窗口相同
  • 最小化按钮:与原窗口相同
  • 最大化按钮:与原窗口相同
  • 关闭按钮:与原窗口相同
  • 标题:与原窗口相同
  • 菜单:如果原窗口有 QMenuBar。则显示窗口的菜单栏。如果太长,可用一个子菜单显示。

实现:建议用 WidgetWindowAgent 派生类实现。

调用close后部分功能失效

当调用close()关闭窗口后,重新显示时标题栏将无法拖动,不知道是否是特性还是bug。
测试方式:
使用QWKExample_MainWindow项目进行测试
修改代码如下:
MainWindow w;
//w.show();
QPushButton button;
QObject::connect(&button, &QPushButton::clicked, [&w] { w.show(); });
button.show();
return a.exec();

我的qt版本6.5.2 vs2022
经过测试
framelesshelper也存在相同的问题

在MacOS中带有代理的窗口里创建新的窗口,销毁第二个窗口时会crash

MacOS下,我有一个带有QWK::WidgetWindowAgent代理的窗口A,在其中再创建一个带有代理的窗口B。销毁窗口B的时候,会crash。
代码如下:
WinKitTest::WinKitTest(QWidget *parent)
: QWidget(parent)
, ui(new Ui::WinKitTest)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);

// frameless agent
m_windowAgent = new QWK::WidgetWindowAgent(this);
m_windowAgent->setup(this);
m_windowAgent->setTitleBar(ui->label);
m_windowAgent->setSystemButton(QWK::WindowAgentBase::Close, ui->pushButton);
m_windowAgent->setHitTestVisible(ui->pushButton_2);

}

WinKitTest::~WinKitTest()
{
delete ui;
qDebug() << "DDDDDDDDDDDDDD";
}

void WinKitTest::on_pushButton_2_clicked()
{
(new WinKitTest())->show();
}

void WinKitTest::on_pushButton_clicked()
{
close();
}

按下pushButton_2创建一个新的WinKitTest。
按下新的WinKitTest中的pushButton,程序就崩溃了。
堆栈如图:
截屏2024-01-05 17 15 27

[Bug]: MSVC 2022/2019 使用 amd64_x86 模式编译会报错

环境信息

  • 操作系统:Windows 11 23H2
  • Qt SDK:MSVC 5.15.2
  • 编译器:MSVC 14.30 或者 14.29

编译指令

cmake -B build -S . -G "Visual Studio 17 2022" -T host=x64 -A win32

报错信息

[cmake] -- Building qmsetup (Release)...
[cmake] -- Installing qmsetup (Release)...
[cmake] CMake Error at CMakeLists.txt:68 (find_package):
[cmake]   Could not find a configuration file for package "qmsetup" that is
[cmake]   compatible with requested version "".
[cmake] 
[cmake]   The following configuration files were considered but not accepted:
[cmake] 
[cmake]     D:/C++_Study/GUI/qwindowkit/build/_install/lib/cmake/qmsetup/qmsetupConfig.cmake, version: 0.0.1.5 (64bit)
[cmake] 
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!

Mac黑色主题下窗口有一个黑色边框,这个怎么去掉

细心观察,这窗口在Mac黑色主题下,有一个黑色的边框,我观察了其他软件的窗口,这个黑色边框也有,但是我观察飞书这个软件时,却没有这个黑色边框,有没有办法去掉这个黑色边框?实际上白色主题也有这个边框,但是不容易观察
image

cmake 编译32位qwindowkit,报错

我用CMake去编译64位和32位的qwindowkit,64位可以正常编译成功,但是尝试编译Win32时,报错
image
父模块设置的是Win32,但是编译出来的子模块qmsetup是64位,子模块并未继承父模块设置的位数,不知道是不是这个原因。有没有办法让子模块继承父模块的位数

QML模式控件位置异常

在QML模式中拖动标题栏会使窗口内的控件错位,应该刚好错位一个标题栏的高度。
另外如果设置qputenv("QSG_RHI_BACKEND", "opengl");的话会使标题栏的y坐标变为负数,也就是在窗口外面。

    Text {
        anchors {
            bottom: parent.bottom
            bottomMargin: 32
            left: parent.left
        }
        font {
            pointSize: 14
            bold: true
        }
        color: "#ECECEC"
        text: 'test'
    }
video.mp4

How to enable Mica/Mica Alt?

#include <windows.h>
#include <dwmapi.h>

MyWidget::MyWidget(QWidget *parent) : QWidget(parent) {
    const auto hwnd = reinterpret_cast<HWND>(winId());
    // We need to extend the window frame into the whole client area to be able to see the blurred window background.
    const auto margins = MARGINS{ -1, -1, -1, -1 };
    ::DwmExtendFrameIntoClientArea(hwnd, &margins);
    // Use official DWM API to enable Mica/Mica Alt, available since Windows 11 (10.0.22000).
    const DWM_SYSTEMBACKDROP_TYPE blurType = DWMSBT_MAINWINDOW; // This one is Mica, if you want to enable Mica Alt, use DWMSBT_TABBEDWINDOW instead.
    ::DwmSetWindowAttribute(hwnd, DWMWA_SYSTEMBACKDROP_TYPE, &blurType, sizeof(blurType));
}

References:

Provide a way that can disable user to resize window by dragging borders

What I want is that we can resize the window programmatically, but disable user to resize window by dragging borders.
In previous project , I find that setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) works as isWidgetFixedSize(in framelesswidgetshelper.cpp line 133) takes sizePolicy into account.
But in current project, the feature disappears, and I don't know how to modify code to achieve the same functionality.
Can you restore the logic of FramelessHelper or tell me another way to do it?
Thanks for reading and hope for your reply!

image

【Mac】macOS 上调试使用blur-effect,未生效

用源代码编译出了库,然后自己用Qt创建了一个Demo并调用这个库,代码直接用的是源码里examples的代码。demo里的颜色切换正常,但是blur-effect切换无效。但是在源码的工程里运行examples,颜色切换正常,blur-effect切换也正常。跟踪调试,发现是setBlurEffect这个函数执行失败,我自己在源码里加了调试信息
7a87bbae5f65b53f44774047ac1c8f5d
examples执行blur-effect切换时,打印如下
5b680f1dea9f3be5043910f2c348e917
我自己写的demo里执行blur-effect切换时,打印如下
8d8c16d3d64b149de174f9112d7dc171
对比之下,发现我自己的demo的打印缺少一个NSVisualEffectView,想问一下,是什么原因导致的

VisualStudio输出窗口大量“参数错误”信息

问题描述:
将鼠标停留在窗口边缘指针变成可拖动模式后,按住左键拖动改变窗口大小,此时VS输出窗口大量显示“参数错误”的信息,淹没其他输出日志,导致没法调试程序。

输出信息如下:
17:04:43:193 clientcore\windows\dwm\dwmapi\attribute.cpp(135)\dwmapi.dll!00007FF862104B63: (caller: 00007FFFF4CC4D59) ReturnHr(1) tid(3adc) 80070057 参数错误。
...
17:04:48:698 clientcore\windows\dwm\dwmapi\attribute.cpp(135)\dwmapi.dll!00007FF862104B63: (caller: 00007FFFF4CC4D59) ReturnHr(74) tid(3adc) 80070057 参数错误。

开发环境如下:
Micrisoft Windows 10 LTSC 企业版21H2(内部版本号19044.3930)
Microsoft Visual Studio Community 2022 (64 位) 版本 17.8.6
Qt Visual Studio Tools 版本3.1.0.2
Vcpkg 版本 2023-11-16-4c1df40a3c5c5e18de299a99e9accb03c2a82e1e
qtbase:x64-windows 版本6.5.3

截图如下:
17067778176691

源代码如下:
QtWidgetsDemo.zip

源代码说明(为了定位问题精简剩下3个文件):

main.cpp:

#include <QtWidgets/QApplication>

#include "mainwindow.h"

int main(int argc, char *argv[]) {
qputenv("QT_WIN_DEBUG_CONSOLE", "attach");
qputenv("QSG_INFO", "1");
#if 0
qputenv("QT_WIDGETS_RHI", "1");
qputenv("QSG_RHI_BACKEND", "d3d12");
qputenv("QSG_RHI_HDR", "scrgb");
qputenv("QT_QPA_DISABLE_REDIRECTION_SURFACE", "1");

QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
    Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);

#endif

QApplication a(argc, argv);

#if 0 && defined(Q_OS_WINDOWS) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QApplication::setFont( {
QFont f("Microsoft YaHei");
f.setStyleStrategy(QFont::PreferAntialias);
f.setPixelSize(15);
return f;
}());
#endif

MainWindow w;
w.show();
return a.exec();

}

mainwindow.h:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtWidgets/QMainWindow>

namespace QWK {
class WidgetWindowAgent;
}

class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;

private:
QWK::WidgetWindowAgent *windowAgent;
};

#endif // MAINWINDOW_H

mainwindow.cpp:

#include "mainwindow.h"

#include <QWKWidgets/widgetwindowagent.h>

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {

windowAgent = new QWK::WidgetWindowAgent(this);

windowAgent->setup(this);

resize(800, 600);

}

MainWindow::~MainWindow() = default;

Linux 交叉编译报错

环境信息

  • 编译器:gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf
  • 操作系统:Ubuntu20.04

报错信息

-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 7.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/toolchain/7.5.0/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at src/syscmdline/CMakeLists.txt:74 (target_compile_features):
  target_compile_features The compiler feature "cxx_std_20" is not known to
  CXX compiler

  "GNU"

  version 7.5.0.


CMake Error at src/corecmd/CMakeLists.txt:25 (target_compile_features):
  target_compile_features The compiler feature "cxx_std_20" is not known to
  CXX compiler

  "GNU"

  version 7.5.0.


-- Configuring incomplete, errors occurred!

Add QGLWidget into demo mainwindow, drag window to another screen, then the window can never be movable

In my program, I use QuarterWidget (which extends QGLWidget) in Coin3D to draw 3D models.
So I test QGLWidget in QWKExample_MainWindow when it's needed to import QWK.
Replace the ClockWidget with QGLWidget, a display error occurred.
Drag window to another screen, the display error disappears, but the window can never be movable by dragging in TitleBar.
setAttribute(Qt::WA_NativeWindow,false) could fix the problem. But the attribute is necessary for QGLWidget.
image
image
P.S. Can you provide apis to specify whether the window can be resizable by dragging borders and if so, the margin can also be customized (as it's 2px hard-coded now)?
Thanks for reading and hope your replys!

基于MainWindow示例代码新增QVideoWidget后导致标题栏无法拖动窗口

After adding a QVideoWidget object to the QWKExample_MainWindow project, I encountered an issue where clicking and dragging the title bar does not move the window. The code is as follows:

MainWindow::MainWindow(QWidget *parent) 
: QMainWindow(parent), m_videoWidget(new QVideoWidget(this)), m_player(new QMediaPlayer(this)) {
    installWindowAgent();

    //auto clockWidget = new ClockWidget();
    //clockWidget->setObjectName(QStringLiteral("clock-widget"));
    //clockWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    //setCentralWidget(clockWidget);

    setCentralWidget(m_videoWidget);
    m_player->setVideoOutput(m_videoWidget);

    loadStyleSheet(Dark);

    setWindowTitle(tr("Example MainWindow"));
    resize(800, 600);
}

After invoking the QMediaPlayer::setVideoOutput interface, there are issues with the window's title bar area, as well as problems with window rendering. However, if you resize the window vertically by dragging the top or bottom borders, the mouse can once again move the window by dragging the title bar area. I encountered the same issue with a simple custom frameless window implementation I had developed earlier. I haven't identified the specific cause yet and hope you can provide a solution.

如何判断操作系统的当前主题

作者您好,之前 framelesshelper 提供的 Utils::shouldUseDarkTheme() 被移除了,好像 qwindowkit 没有提供相同功能的接口,是否有考虑把这个接口加回来呢?

无法将项目设置为子项目

当我将qwindowkit作为子项目并链接时,发生错误
export called with target "XXXX" which requires target "QWKWidgets"
that is not in any export set.

macos编译报错

[ 45%] Linking CXX shared library ../../out-arm64-/lib/libQWKCore.dylib

ld:` warning: ignoring file '/Users/user/Qt5.14.2/5.14.2/clang_64/lib/QtGui.framework/Versions/5/QtGui': found architecture 'x86_64', required architecture 'arm64'

你好,请问报这个错误是咋回事啊?我按照readme中的步骤来构建。系统是macos 13.5,芯片是apple m2 pro。
提前谢谢了

Cannot restore geometry in showEvent

First of all let me say that this might or might not be a bug, let me explain.

I used to save the geometry of my MainWindow in hideEvent and restore it (setGeometry) in showEvent with FramelessHelper and that used to work flawlessly.

When using qwindowkit however, restoring the geometry in showEvent doesnt work anymore. I have to set it again, after mainWindow->show(); is called.

Before with FramelessHelper:

class MainWindow
{
	void hideEvent(QHideEvent* event)
	{
		// save geometry
	}

	void showEvent(QShowEvent* event)
	{
		// restore geometry
	}
};

MainWindow* main = new MainWindow();
main->show();

Now with qwindowkit:

class MainWindow
{
	void hideEvent(QHideEvent* event)
	{
		// save geometry
	}

	void showEvent(QShowEvent* event)
	{
		// restore geometry - DOESNT WORK
	}
};

MainWindow* main = new MainWindow();
main->show();
main->setGeometry(geo);  // HAVE TO DO IT HERE NOW

Rendering a QQuickWindow with OpenGL causes title bar issues

Setting up a Quick application with QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL) causes some issues with the title bar. I have observed the following:

  • On initial window loading, the bar is not visible.
  • Resizing on the right and/or the bottom edges makes the bar visible
  • Resizing on the left and/or top edges makes the bar invisible
  • When the bar is visible, using it to drag the window around makes it invisible.

I presume it is not actually invisible, just somewhere out of sight further up, since content that is anchored to the title bar gets shifted upwards when the bar is not visible.

OS: Windows 10 Pro (22H2, Build 19045.3803)
Qt: 6.5.3

开启无边框窗口后鼠标位置映射异常

操作系统:Win10 22H2
Qt版本:6.7.0
使用如下代码测试:

import QtQuick 
import QtQuick.Window 
import QtQuick.Controls 
import Qt.labs.platform 
import QWindowKit

Window {
    id: window
    width: 800
    height: 600
    title: qsTr("Hello, world!")
    Component.onCompleted: {
        windowAgent.setup(window)
        window.visible = true
    }

    WindowAgent {
        id: windowAgent
    }

    MouseArea{
        anchors.fill: parent
        onPressed: (mouse)=>{
               var global = mapToGlobal(mouse.x,mouse.y)
               helper.setCursorPos(global.x,global.y)
               var local = mapFromGlobal(global.x,global.y)
               console.log("mouse:",mouse.x,mouse.y,"  global:",global," local:",local)
        }
    }

helper.setCursorPos(global.x,global.y) 是一个C++提供的函数,它仅仅是调用QCursor::setPos(x, y)
目前发现开启无边框窗口后,mapToGlobal得到的鼠标位置跟实际的鼠标位置会相差一个标题栏的高度,但是再使用mapFromGlobal还原得到的本地坐标确实正确的

表现情况如下:
asd

在win上实现圆角Dialog

在win上实现圆角的dialog
我用Qt::FramelessWindowHint特性,然后自己绘制阴影和背景,虽然可以实现,但是原来系统自带的效果(如:点击窗口外部,弹窗阴影闪烁)没有了,我希望在保留系统特性的情况下,实现圆角dialog

1920x1080屏幕下,设置qml窗口大小为1920x1080时,启动程序后屏幕左边会有几个像素的空白

相关qml设置如下:

ApplicationWindow {
    id: window
    visible: false // We hide it first, so we can move the window to our desired position silently.

    minimumHeight: 1080
    minimumWidth: 1920
    width: 1920
    height: 1080

屏幕大小:1920x1080
之前没有问题,打开程序后,程序窗口是靠紧屏幕左边的。
前几天更新代码库后,发现,程序启动后,屏幕左边会空白几个像素的空白,不确定是否是最近的代码更新造成的。
如下图(最左边边缘一条蓝色的是屏幕左边背景蓝色,请点开图片查看,看缩略图看不出来。):
image

以使用QWK的窗口为父窗口弹出另一个使用QWK的子窗口,父窗口丢失QWK特性

如下图所示,在example代码中创建MainWindow w1,并创建以w1为父窗口的w2。
两个窗口显示后,即使w2使用的是show不是exec,w1仍不能移动,右键无法触发系统菜单,也丢失了SnapLayout的特性。关掉w2后也无法恢复正常。而当我设置MainWindow属性为Qt::WA_DeleteOnClose,关闭w2,发生了崩溃,这是不合理的。
在我的项目中,我打算完全引入QWK作为无边框窗口的解决方案,所以软件窗口打开的情况下,会频繁地弹出子对话框,这个问题是致命的,希望作者能关注下。
image

Qt5.12.10 编译失败

尊敬的作者,您好,
目前测试Qt5.12.10 + VS2019编译出错,
1, 缺少头文件<QtCore/private/qwinregistry_p.h>, 这个我找了一下,确实5.12没有这个文件
2,缺少Q_DISABLE_COPY_MOVE这个宏

Windows11 窗口阴影颜色问题

问题描述

作者您好,我在用 qwindowkit 的过程中发现窗口阴影颜色有点奇怪,会比其他窗口的阴影更黑:
image

环境信息

  • Qt 5.15.2 MinGW
  • Windows11 23H2

最小复现代码:

TestWindowKit.zip

最新代码win32编译仍然报错

步骤

1、管理员打开x64_x86 Cross Tools Command Prompt for VS 2019

2、git clone --recursive https://github.com/stdware/qwindowkit

3、cd qwindowkit

4、cmake -B build -S . -Dqmsetup_DIR=E:/Develop/2019/QWindowKit/qmsetup -DCMAKE_INSTALL_PREFIX=E:/Develop/2019/QWindowKit -G "Visual Studio 16 2019" -A Win32

提示

E:\Develop\2019\QWindowKit>cmake -B build -S . -Dqmsetup_DIR=E:/Develop/2019/QWindowKit/qmsetup -DCMAKE_INSTALL_PREFIX=E:/Develop/2019/QWindowKit -G "Visual Studio 16 2019" -A Win32
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The CXX compiler identification is MSVC 19.29.30147.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring qmsetup...
-- Building qmsetup (Release)...
-- Installing qmsetup (Release)...
CMake Error at CMakeLists.txt:68 (find_package):
  Could not find a configuration file for package "qmsetup" that is
  compatible with requested version "".

  The following configuration files were considered but not accepted:

    E:/Develop/2019/QWindowKit/build/_install/lib/cmake/qmsetup/qmsetupConfig.cmake, version: 0.0.1.5 (64bit)

不加-A Win32没问题

在构建树中包含项目并导出时出错

举例:
我有个库A引用qwindowkit
target_link_libraries(A PUBLIC
QWindowKit::Core
)

此时构建是没有任何问题的。
但是当按照
https://cmake-doc.readthedocs.io/zh-cn/latest/guide/importing-exporting/index.html
进行导出安装后
install()...
install()...
export(EXPORT ATargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/Aargets.cmake"
NAMESPACE ${NAMESPACE}::
)
关键是使用export之后
在生成阶段会报错:
export called with target "A" which requires target "QWKCore" that is
not in any export set.

我需要使用export()使A在构建树中的其他项目可见

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.