A bit about fixed sized dialogs in Qt

Most of the time, it makes the most sense for our dialogs to be designed with layouts such that it looks good with just about any width or height. But there are a few cases where locking in the size makes sense. The most classic example I can think of is an "about this application" dialog box.


When you are editing a dialog window in the Qt designer, there is a sizePolicy property which among other things can be set to Fixed. And while you may assume like I did that this would create a fixed-sized dialog, sadly, this is not the property we're looking for.

Fortunately, it's a one-liner to get the behavior we want, so I figure I'd share my findings :-).

We can simply add the following to the constructor of our dialog class after the call to setupUi.

setFixedSize(width(), height());

This will make the dialog non-resizable. I would have expected a Fixed size policy to make our dialogs fixed size. Unfortunately, this doesn't seem to be the case. For a while, I had hoped to find a solution that could be implemented in the designer itself but to no avail.