Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, March 2002
QWidget::polish () is called BEFORE it's fully created


Message 1 in thread

Hi:

The Qt Document says about void QWidget::polish ();

"This function will be called AFTER a widget has been fully 
created and before it is shown the very first time."

But if you call some QLayout methods in constructor, 
QWidget::polish () would be called (BEFORE the object is 
fully created). This causes the application crashed. I 
think it may be a BUG of Qt.

For example:

MyWidget::MyWidget (QWidget* inParent)
    : QWidget (inParent), m_childWidget (0)
{
    QVBoxLayout* baseLayout = new QVBoxLayout (this, 0, 0);
    baseLayout->setResizeMode (QLayout::Minimum);

    m_childWidget = new QLabel (this);
    baseLayout->addWidget (m_childWidget);
}


void
MyWidget::polish ()
{
    QWidget::polish ();
    m_childWidget->setText ("Foo");
}

In this code, line 5, calling QVBoxLayout::setResizeMode 
evokes MyWidget::polish () method in spite that the object 
is not created completely, and the process would receive 
SEGV.

Anyone have information?

Naoyuki