[Qt-interest] setSizePolicy has no effect in subclass of QDialog

Farid Derradji farid.derradji at ITWM.fraunhofer.de
Tue Jun 2 19:12:56 CEST 2009


Hello Stephen,

> I've found a way to achieve what I want in designer: if you click
> on the form background, there is a context menu "Size constraints"
> from which you can set min/max height/width. If you reduce the design
> form to its maximum desired height, and set "Size Constraints"->
> "Set Maximum Height", then the dialog cannot be resized vertically.

After studying the official documentation I am convinced that you are on
the right way. The following code skeleton principally describes what Qt
Designer implemented for you:


HEADER

class MyDialog : public QDialog
{
  Q_OBJECT

  ...

  // .constructor ------------------------------------
  MyDialog (...);

  ...

  // .member -----------------------------------------
  QLayout m_pLayout;

  ...

};



SOURCE CODE

MyDialog::MyDialog (...)
{

  ...

  m_pLayout->setSizeConstraint (QLayout::SetMaximumSize);

  ...
}

...



EXPLANATION

According to the official documentation your dialog's maximum size is
set to QLayout::maximumSize().



Regards
Farid



More information about the Qt-interest-old mailing list