Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
4.6.3, 4.7.0, 4.7.1, 4.7.2
-
None
Description
In the code below, without the call to update(), the region exposed is not updated properly.
#include <QtGui> class ChildWidget : public QWidget { Q_OBJECT public: ChildWidget(const QRect &rect, QWidget *parent = 0):QWidget(parent, Qt::FramelessWindowHint) { setGeometry(rect); QPushButton* pButton = new QPushButton("Test", this); connect(pButton, SIGNAL(clicked()), this, SIGNAL(nextButtonClicked())); } signals: void nextButtonClicked( ); }; class ParentWidget : public QWidget { Q_OBJECT public: explicit ParentWidget(QWidget *parent = 0); public slots: void openChild( ); private slots: void childDestroyed(QObject*); private: QLabel* movableLabel; bool posflag; }; ParentWidget::ParentWidget(QWidget *parent) : QWidget(parent, Qt::FramelessWindowHint), posflag(true) { setGeometry(45, 110, 150, 100); movableLabel = new QLabel(this); movableLabel->setGeometry(0, 0, 120, 150); QLabel *pLabel; QPushButton* pButton; pButton = new QPushButton(QString("0000"), movableLabel); pButton->setGeometry(20, 0, 50, 45 ); pLabel = new QLabel(QString("0000"), movableLabel); pLabel->setGeometry(70 ,0, 120, 45 ); pButton = new QPushButton(QString("1111"), movableLabel); pButton->setGeometry(20, 50, 50, 45 ); pLabel = new QLabel(QString("1111"), movableLabel); pLabel->setGeometry(70 ,50, 120, 45 ); pButton = new QPushButton(QString("2222"), movableLabel); pButton->setGeometry(20, 100, 50, 45 ); pLabel = new QLabel(QString("2222"), movableLabel); pLabel->setGeometry(70 ,100, 120, 45 ); } void ParentWidget::openChild( ) { posflag = !posflag; QRect childRect(84, 100 /* <- less than 110 to reproduce */ + (100*(posflag ? 1 : 0)), 150, 130); ChildWidget *child = new ChildWidget(childRect); child->show(); // update(); connect(child, SIGNAL(nextButtonClicked()), child, SLOT(deleteLater())); connect(child, SIGNAL(destroyed(QObject*)), this, SLOT(childDestroyed(QObject*))); connect(child, SIGNAL(destroyed(QObject*)), this, SLOT(openChild())); // reopen } void ParentWidget::childDestroyed(QObject*) { // toggle label position if(movableLabel->pos().y() == 0 ) { movableLabel->move(0,-100); // hide 0000 and 1111, show 2222 } else { movableLabel->move(0,0); // show 0000 and 1111, hide 2222 } } int main( int argc, char *argv[] ) { QApplication app(argc, argv); ParentWidget w; w.show(); w.openChild( ); return app.exec(); } #include "main.moc"