Qt界面篇:Qt没有真正完美的无边框解决方案吗?qwindowkit推荐!

博客介绍了在Qt中解决无边框窗口问题的挑战,推荐了qwindowkit库,并提供了源码下载地址、编译指南及使用示例,帮助开发者实现完美的无边框效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、Qt边框问题

  在使用QWidget或QMainWindow时,关于标题栏无法设定背景以及拖动的问题,与windows系统显得格格不入。尝试过很多种方案,都无法真正完美的实现无边框方案,最近看到大佬的无边框库,感觉挺好用,于是赶紧编译使用了一下,在此进行记录:qwindowkit地址
在这里插入图片描述

原生QMainWindow:
在这里插入图片描述

2、源码下载地址

  qwindowkit下载地址
在这里插入图片描述

3、源码cmake编译

  Windows: MSVC: 2019, 2022 + Qt 5.12 or higher。直接编译即可。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4、使用方式

效果:
在这里插入图片描述

  1)在main函数进行如下设定:

 QGuiApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#include "QtWidgetsTest.h"
#include <QtWidgets/QApplication>
#include "QWKWidgets/qwkwidgetsglobal.h"

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

    QApplication a(argc, argv);
    QtWidgetsTest w;
    w.show();
    return a.exec();
}

  2)在Mainwindow函数进行如下设定:

	windowAgent = new QWK::WidgetWindowAgent(this);
	windowAgent->setup(this);
	auto windowBar = new QWK::WindowBar();
	auto iconButton = new QWK::WindowButton();
	iconButton->setObjectName(QStringLiteral("icon-button"));
	iconButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);

	auto minButton = new QWK::WindowButton();
	minButton->setObjectName(QStringLiteral("min-button"));
	minButton->setProperty("system-button", true);
	minButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);

	auto maxButton = new QWK::WindowButton();
	maxButton->setCheckable(true);
	maxButton->setObjectName(QStringLiteral("max-button"));
	maxButton->setProperty("system-button", true);
	maxButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);

	auto closeButton = new QWK::WindowButton();
	closeButton->setObjectName(QStringLiteral("close-button"));
	closeButton->setProperty("system-button", true);
	closeButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);

	windowBar->setIconButton(iconButton);
	windowBar->setMinButton(minButton);
	windowBar->setMaxButton(maxButton);
	windowBar->setCloseButton(closeButton);
	windowAgent->setTitleBar(windowBar);

5、示例源码下载

下载源码

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

欧特克_Glodon

很高兴能帮助到您!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值