Название: QEvent::ChildPolished
Отправлено: vertus от Мая 29, 2012, 14:10
Всем доброго времени суток!
Что это за событие такое? В документации это сепулька какая-то - "A widget child gets polished".
Спасибо за внимание!
Название: Re: QEvent::ChildPolished
Отправлено: V1KT0P от Мая 29, 2012, 16:06
Что это за событие такое? В документации это сепулька какая-то - "A widget child gets polished".
Если верить этому переводу: http://qtdocs.narod.ru/4.1.0/doc/html/qevent.html (http://qtdocs.narod.ru/4.1.0/doc/html/qevent.html) то это "Настраивается дочерний объект виджета". Если бегло посмотреть исходники Qt, то звучит правдоподобно.
Название: Re: QEvent::ChildPolished
Отправлено: vertus от Мая 29, 2012, 16:20
Т.е. конструктор дочернего виджета отрабатывает?
Название: Re: QEvent::ChildPolished
Отправлено: V1KT0P от Мая 29, 2012, 16:37
Т.е. конструктор дочернего виджета отрабатывает?
Вот кусок кода с описанием: C++ (Qt) /*! Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). QWidget calls this function after it has been fully constructed but before it is shown the very first time. You can call this function if you want to ensure that the widget is polished before doing an operation, e.g., the correct font size might be needed in the widget's sizeHint() reimplementation. Note that this function \e is called from the default implementation of sizeHint(). Polishing is useful for final initialization that must happen after all constructors (from base classes as well as from subclasses) have been called. If you need to change some settings when a widget is polished, reimplement event() and handle the QEvent::Polish event type. \bold{Note:} The function is declared const so that it can be called from other const functions (e.g., sizeHint()). \sa event() */ void QWidget::ensurePolished() const { Q_D(const QWidget); const QMetaObject *m = metaObject(); if (m == d->polished) return; d->polished = m; QEvent e(QEvent::Polish); QCoreApplication::sendEvent(const_cast<QWidget *>(this), &e); // polish children after 'this' QList<QObject*> children = d->children; for (int i = 0; i < children.size(); ++i) { QObject *o = children.at(i); if(!o->isWidgetType()) continue; if (QWidget *w = qobject_cast<QWidget *>(o)) w->ensurePolished(); } if (d->parent && d->sendChildEvents) { QChildEvent e(QEvent::ChildPolished, const_cast<QWidget *>(this)); QCoreApplication::sendEvent(d->parent, &e); } }
То-есть событие вызывается после всех конструкторов, но перед первым отображением.
Название: Re: QEvent::ChildPolished
Отправлено: vertus от Мая 29, 2012, 16:38
Ага, спасибо за ответ!
|