I'm building an application that has its own custom chrome. I have turned the default window border off by setting the flag:
this->setWindowFlags(Qt::FramelessWindowHint);
After this flag is set and the default window border is turned off, any calls to:
this->showMaximized();
result in a window that takes up the entire screen, overlapping the task bar. Is there a common work around for this or another method I should be calling instead of showMaximized()?
Win7/Qt4.6
If you inherit from QDesktopWidget, you'd be able to use availableGeometry(), which returns the available geometry of the screen with index screen based on what the platform decides is available (for example excludes the dock and menu bar on Mac OS X, or the task bar 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()
{
}
You should not inherit from QDesktopWidget
.
You can get the "available geometry" by getting the QDesktopWidget
instance 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());