Qt/win:showMaximized() 在无框窗口上重叠任务栏
我正在构建一个没有默认窗口边框的 Qt 应用程序作为无框窗口。 窗口函数是通过在 QMainWindow 中设置窗口标志来包含的,例如:
MainDialog::MainDialog(QWidget *parent):
QMainWindow(parent), currentProject(NULL), currentUser(NULL),
aViews(new QList<AViewForm*>()),
bViews(new QList<BViewForm*>()),
cViews(new QList<CViewForm*>())
{
ui.setupUi(this);
this->statusBar()->showMessage(tr(""));
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowSystemMenuHint);
...
}
MainWindow 内有一个 .ui 文件,这就是为什么我无法从 QDesktopWidget 继承。 我现在遇到的问题是应用程序在最大化时覆盖 Windows 任务栏。
情况下找出操作系统桌面的可用高度
availableGeometry().height()
我现在的问题:是否有可能在没有QDesktopWidget 的方法的 ?我在文档中找不到任何内容:(
这里其他人问了类似的 问题,但使用了 QWidget 而不是 QMainWindow,
我很高兴收到有关我的问题的任何提示。
I'm building an Qt-Application without the default window border as a frameless window.
The window functions are included by setting window flags in the QMainWindow like:
MainDialog::MainDialog(QWidget *parent):
QMainWindow(parent), currentProject(NULL), currentUser(NULL),
aViews(new QList<AViewForm*>()),
bViews(new QList<BViewForm*>()),
cViews(new QList<CViewForm*>())
{
ui.setupUi(this);
this->statusBar()->showMessage(tr(""));
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowSystemMenuHint);
...
}
The MainWindow has an .ui file within, thats why I cannot inherit from QDesktopWidget.
The Problem I have now is that the Appication overlays the windows taskbar when maximizing.
My Question now: is there any posibility to find out the available height of the OS desktop without the
availableGeometry().height()
-Method of QDesktopWidget? I cannot find anything in the documentation :(
Somebody else here asked a similar Question but used a QWidget instead of a QMainWindow.
I would be glad about any hints to my Problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如你所说,你可以使用 QDesktopWidget。如果您没有从它继承的类,您可以在构造函数中创建一个仅用于检索高度的类:
As you say you can use QDesktopWidget. If you don't have your class inherit from it you can create one in your constructor just for retrieving the height :
我猜这不是一个好的做法,但我解决了它,如下所示:
我构建了一个新类,它需要一个 MainWindow 作为参数,并带有用于缩放操作的插槽:
现在出现的唯一问题是当应用程序全屏并且移动任务栏时。我还没有设置任何 resizeEvent
Guess thats not good practise, but i solved it as followed:
I built a new class which needs a MainWindow as param and with slots for the scaling actions:
The only Problem which now occures is when the application is fullscreen and you move the taskbar. I have not set any resizeEvent though