Reputation: 2584
I am trying to maximize my main qt window upon running and prevent the user from resizing it. I have tried
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow widget;
widget.showMaximized();
widget.show();
return a.exec();
}
Which does maximize the window, along with
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
this->setWindowFlags(this->windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
ui->setupUi(this);
}
which does grey out the "restore down", "maximize" button located in the title bar in the middle of minimize and close window.
But I am still able to drag the title bar down to unsnap the maximized window and then readjust the size with the corner and edges.
How can I prevent the ability to unsnap the window and no strictly no resizing.
Thanks!
Upvotes: 6
Views: 9441
Reputation: 733
If you want Window frame disappear and maximize-lose-restoredown buttons invisible, you can modify UI part of your code as:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
this->setWindowFlags(this->windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //Makes the frame invisible
this->setWindowState(Qt::WindowMaximized); //Maximizes the window
}
Upvotes: 5