Lock the window zoom

Asked

Viewed 457 times

5

How can I block the window rise QDialog and QWidget?

For example, in the Skype login window you cannot enlarge the window.

3 answers

3

In the builder you can do the following:

setFixedSize(size());

Or still to use recommended size instead of standard:

setFixedSize(sizeHint());

So the maximum and minimum window size will be set to the same value, it will not be resizable.

A better way to do this (which will resize the window if the content changes, but will always make the window ideal for your content) is by using QLayout::SetFixedSize. See the response from C. E. Gesser.

Additionally, you can set the flag Qt::MSWindowsFixedSizeDialogHint which in Windows creates a thin-edged window, visually indicating to the user that it is not resizable.

setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
  • Blz. I added in Qdialog. Another question in Mainwindows. I would like you to redirect the components of the layout when enlarging the window. you know how to do this?

  • @user628298 In understanding the question, using layouts the components naturally resize to the container size. But it seems unrelated, it probably fits open a new question.

  • Okay, I’ll create a new question. thanks for the help.

3

You can use the method setFixedSize(const QSize &) class QWidget to set a fixed size for a window. In practice it sets the maximum and minimum window size for the value that is passed by parameter.

If you want the size to be fixed but based on the window components, use the setSizeConstraint(SizeConstraint) class QLayout, with the parameter SetFixedSize:

layout()->setSizeConstraint(QLayout::SetFixedSize);
  • Blz. added in Qdialog. Another question in Mainwindows(Qwidget). I would like you to redirect the layout components when enlarging the window. you know how to do this?

  • @user628298 This would be the normal thing to happen when using layouts. Maybe you can edit the question by adding this doubt, and indicating which layout you’re using and maybe a screenshot of how it’s going wrong. Or maybe you’d better ask yourself another question.

  • Okay, I’ll create a new question. thanks for the help.

1

You can use the method setFixedSize to do this.

Example:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.