We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
你好,我使用QDialog作为子窗口,也想使用和主窗口一样的效果。主窗口使用QWK可以实现自定义的标题栏样式,我想实现QDialog子窗口也有同样的样式,但是使用之后发现QDialog无法拖动,设置样式背景颜色之后,会将关闭按钮的hover效果屏蔽掉。我的使用方法如下:
void MainWindow::onCommonSetting() { CommonSettingWidget* commonDlg = new CommonSettingWidget(this); commonDlg->exec(); }
CommonSettingWidget::CommonSettingWidget(QWidget *parent) : QDialog(parent), ui(new Ui::CommonSettingWidget) { ui->setupUi(this); // 窗口代理 windowAgent = new QWK::WidgetWindowAgent(this); windowAgent->setup(this); // 关闭按钮 auto closeButton = new QWK::WindowButton(); closeButton->setObjectName(QStringLiteral("close-button")); closeButton->setProperty("system-button", true); closeButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); // 创建窗口标题栏 auto windowBar = new QWK::WindowBar(this); windowBar->setCloseButton(closeButton); auto titleLabel = new QLabel(); titleLabel->setAlignment(Qt::AlignCenter); titleLabel->setObjectName(QStringLiteral("win-title-label")); windowBar->setTitleLabel(titleLabel); windowBar->setHostWidget(this); windowAgent->setSystemButton(QWK::WindowAgentBase::Close, windowBar->closeButton()); connect(windowBar, &QWK::WindowBar::closeRequested, this, &QWidget::close); this->layout()->setMenuBar(windowBar); }
还请大佬帮忙看下。 下图是实现的QDialog子窗口:
感觉是不是我的
this->layout()->setMenuBar(windowBar);
这个代码有问题。
The text was updated successfully, but these errors were encountered:
在main函数里有没有加入初始化代码:
QGuiApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
没有的话加一下,仔细看README。
Sorry, something went wrong.
我是照着ReadMe文件添加的,主函数也是加了这个的 我是这样加的,应该没问题吧, 我是在windows11系统上
我看错了,我看成MainWindow无法拖动了。Dialog无法拖动是因为你少写了一句
windowAgent->setTitleBar(windowBar);
建议仔细看README。
感谢大佬,确实是漏了这一个,加上之后可以了
No branches or pull requests
你好,我使用QDialog作为子窗口,也想使用和主窗口一样的效果。主窗口使用QWK可以实现自定义的标题栏样式,我想实现QDialog子窗口也有同样的样式,但是使用之后发现QDialog无法拖动,设置样式背景颜色之后,会将关闭按钮的hover效果屏蔽掉。我的使用方法如下:
还请大佬帮忙看下。
下图是实现的QDialog子窗口:
感觉是不是我的
这个代码有问题。
The text was updated successfully, but these errors were encountered: