Qt / win: showMaximized () overlapping taskbar in a frameless window

I am creating an application that has its own chrome. I disabled the default window border by setting a flag:

this->setWindowFlags(Qt::FramelessWindowHint); 

After this flag is set, and the window border is disabled by default, any calls:

 this->showMaximized(); 

will lead to a window that occupies the entire screen, overlapping the taskbar. Is there any general work for this or another method that I should call instead of showMaximized ()?

Win7 / Qt4.6

+6
qt qt4
source share
2 answers

If you inherit from QDesktopWidget, you can use the available Geometry (), which returns the available screen geometry with the index screen depending on what the platform decides (for example, excludes the docking station and menu bar on Mac OS X or the taskbar on Windows) .

 #ifndef WIDGET_H #define WIDGET_H #include <QtGui> class Widget : public QDesktopWidget { Q_OBJECT public: Widget(QWidget *parent = 0); ~Widget(); }; #endif // WIDGET_H #include "widget.h" #include <QtGui> Widget::Widget(QWidget *parent) : QDesktopWidget() { this->setWindowFlags(Qt::FramelessWindowHint); this->showMaximized(); this->resize(width(), availableGeometry().height()); } Widget::~Widget() { } 
+5
source share

You should not inherit from QDesktopWidget .

You can get "available geometry" by getting an instance of QDesktopWidget from QApplication :: desktop :

 QDesktopWidget *desktop = QApplication::desktop(); // Because reserved space can be on all sides of the scren // you have to both move and resize the window this->setGeometry(desktop->availableGeometry()); 
+7
source share

All Articles