[Interest] Window flicker when layout's size constraint is Fixed

Kimmo Viitanen kviitanen at gmail.com
Thu Feb 2 20:08:41 CET 2012


Hi,

> I want the size of the dialog to change depending on the visible
> widgets, so I have set the layout used in the dialog to have
> QLayout::SetFixedSize as it's size constraint.

The documentation for SetFixedSize says

"The main widget's size is set to sizeHint(); it cannot be resized at all."

So the size is calculated constantly. I have to, though, that for me 
with Qt 4.8.0 on Linux Mint 11, the effect is not nearly as bad as it 
shows in your video. It is actually very smooth and quick, so perhaps 
this is some platform issue. For this reason I'm not sure if this helps 
in your case, but it "appears" to me that the dialog is not constantly 
changing size with the following change.



void on_checkBox_toggled(bool isChecked) {
         if (isChecked)
             this->layout()->setSizeConstraint(QLayout::SetMaximumSize);
         else
             this->layout()->setSizeConstraint((QLayout::SetMinimumSize));

		//setUpdatesEnabled(false);
		comboBox->setVisible(isChecked);
		comboBox1->setVisible(isChecked);
		comboBox2->setVisible(isChecked);
		comboBox3->setVisible(isChecked);
		comboBox4->setVisible(isChecked);
		comboBox5->setVisible(isChecked);
		comboBox6->setVisible(isChecked);
		//setUpdatesEnabled(true);

         this->layout()->setSizeConstraint(QLayout::SetFixedSize);
	}


Cheers,

Kimmo



More information about the Interest mailing list