[Qt-interest] QWidget background color
Malyushytsky, Alex
alex at wai.com
Fri Sep 24 00:52:46 CEST 2010
Try to call invalidate() on layout after you made changes.
Regards,
Alex
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Leonardo M. Ramé
Sent: Thursday, September 23, 2010 12:21 PM
To: Qt Interest
Subject: [Qt-interest] QWidget background color
Hi, my app consists of a main window with a QGridLayout, where I add
custom QWidgets dynamically with layout->addWidget(new MyWidget(), x,
y).
The user can change the layout choosing from 1x1, 1x2, 2x1, 2x2 and 3x3.
My problem is, whenever the user changes the layout, I remove the
previous disposition and recreate it again with the user's selection,
but the widgets are not painted correctly, until I click on them.
How can I solve this?.
This is the code to remove and re-generate the layout:
// remove
for(int i = layout->count() - 1; i >= 0; i--)
{
QWidget * widget = layout->itemAt(i)->widget();
delete widget;
delete layout->itemAt(i);
layout->removeItem(layout->itemAt(i));
}
// re-create
switch(i)
{
case 0:
layout->addWidget(new DCMWidget(), 0, 0);
break;
case 1:
layout->addWidget(new DCMWidget(), 0, 0);
layout->addWidget(new DCMWidget(), 0, 1);
break;
case 2:
layout->addWidget(new DCMWidget(), 0, 0);
layout->addWidget(new DCMWidget(), 1, 0);
break;
case 3:
layout->addWidget(new DCMWidget(), 0, 0);
layout->addWidget(new DCMWidget(), 0, 1);
layout->addWidget(new DCMWidget(), 1, 0);
layout->addWidget(new DCMWidget(), 1, 1);
break;
...
}
--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
“Please consider our environment before printing this email.”
More information about the Qt-interest-old
mailing list