Keep object name of QWidgetWindow in sync with the widget.

Use new objectNameChanged() signal.

Change-Id: I247566bd51d23ec65ff74ba9ac7be0d18e8ff160
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
Friedemann Kleint 2012-05-10 16:57:41 +02:00 committed by Qt by Nokia
parent fe59f15a5b
commit 78b9de746c
3 changed files with 14 additions and 10 deletions

View File

@ -9074,16 +9074,6 @@ void QWidget::ensurePolished() const
QChildEvent e(QEvent::ChildPolished, const_cast<QWidget *>(this));
QCoreApplication::sendEvent(d->parent, &e);
}
if (d->extra && d->extra->topextra && d->extra->topextra->window
&& d->extra->topextra->window->objectName().isEmpty()) {
QString on = objectName();
if (on.isEmpty()) {
on = QString::fromUtf8(metaObject()->className());
on += QStringLiteral("Class");
}
on += QStringLiteral("Window");
d->extra->topextra->window->setObjectName(on);
}
}
/*!

View File

@ -60,6 +60,8 @@ extern bool qt_try_modal(QWidget *widget, QEvent::Type type);
QWidgetWindow::QWidgetWindow(QWidget *widget)
: m_widget(widget)
{
updateObjectName();
connect(m_widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName);
}
#ifndef QT_NO_ACCESSIBILITY
@ -507,4 +509,13 @@ bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long
return m_widget->nativeEvent(eventType, message, result);
}
void QWidgetWindow::updateObjectName()
{
QString name = m_widget->objectName();
if (name.isEmpty())
name = QString::fromUtf8(m_widget->metaObject()->className()) + QStringLiteral("Class");
name += QStringLiteral("Window");
setObjectName(name);
}
QT_END_NAMESPACE

View File

@ -83,6 +83,9 @@ protected:
void handleWindowStateChangedEvent(QWindowStateChangeEvent *event);
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
private slots:
void updateObjectName();
private:
void updateGeometry();