PDA

View Full Version : How do I prevent the user from resizing the application window?



arcelivez
18th August 2010, 07:56
Well since I've been searching for a clear answer on this and didn't find it easy to figure out how to do it, anyway, I hope this will help someone in the future.

So if you want to prevent the window from being resized, let it be QWidget or QDialog or QMainWindow, well for me this worked:

Just type in this line in the constructor:

this->setFixedSize(this->size().width(), this->size().height());

Or you can just specify a different size obtained from variables... But that's how it perfectly worked for me, for all my dialogs.

Just another example of how to use it:



MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setFixedSize(this->size().width(), this->size().height());
}


Hope this is going to be useful for people searching for this in the future. :)

The Storm
18th August 2010, 13:39
Yes, the fixed size is a bit hidden. :P Such things you can post to the wiki, because your topic will move on and because the search engine of the forum is a bit buggy(at last for me) it will be easier for the users to find this info in to the wiki. ;)