QWidget: mark obsolete function isTopLevel() as deprecated

QWidget::isTopLevel() is deprecated and can be replaced 1:1 with
isWindow(). Sadly it's was not marked with Q_DECL_DEPRECATED in 5.15

Change-Id: I4508fbde41927f3b82e47a75011179548325029d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Christian Ehrlicher 2020-09-04 21:09:44 +02:00
parent ac09bd40fa
commit ff8d757e22
5 changed files with 9 additions and 6 deletions

View File

@ -1328,7 +1328,7 @@ void QWidgetPrivate::create()
if (!store) {
if (q->windowType() != Qt::Desktop) {
if (q->isTopLevel())
if (q->isWindow())
q->setBackingStore(new QBackingStore(win));
} else {
q->setAttribute(Qt::WA_PaintOnScreen, true);
@ -11855,7 +11855,7 @@ void QWidget::setBackingStore(QBackingStore *store)
{
// ### createWinId() ??
if (!isTopLevel())
if (!isWindow())
return;
Q_D(QWidget);
@ -11872,7 +11872,7 @@ void QWidget::setBackingStore(QBackingStore *store)
if (!repaintManager)
return;
if (isTopLevel()) {
if (isWindow()) {
if (repaintManager->backingStore() != oldStore && repaintManager->backingStore() != store)
delete repaintManager->backingStore();
repaintManager->setBackingStore(store);

View File

@ -230,7 +230,10 @@ public:
void setStyle(QStyle *);
// Widget types and states
#if QT_DEPRECATED_SINCE(6, 2)
QT_DEPRECATED_VERSION_X_6_1("Use isWindow()")
bool isTopLevel() const;
#endif
bool isWindow() const;
bool isModal() const;

View File

@ -800,7 +800,7 @@ void QWidgetWindow::handleMoveEvent(QMoveEvent *event)
auto oldPosition = m_widget->data->crect.topLeft();
auto newPosition = geometry().topLeft();
if (!m_widget->isTopLevel()) {
if (!m_widget->isWindow()) {
if (auto *nativeParent = m_widget->nativeParentWidget())
newPosition = m_widget->parentWidget()->mapFrom(nativeParent, newPosition);
}

View File

@ -1091,7 +1091,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
QColor dimHighlight(qMin(highlight.red()/2 + 110, 255),
qMin(highlight.green()/2 + 110, 255),
qMin(highlight.blue()/2 + 110, 255));
dimHighlight.setAlpha(widget && widget->isTopLevel() ? 255 : 80);
dimHighlight.setAlpha(widget && widget->isWindow() ? 255 : 80);
QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()));
gradient.setColorAt(0, dimHighlight.lighter(120));
gradient.setColorAt(1, dimHighlight);

View File

@ -2593,7 +2593,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
continue;
if (!qobject_cast<QDockWidget*>(w) && !qobject_cast<QDockWidgetGroupWindow *>(w))
continue;
if (w != widget && w->isTopLevel() && w->isVisible() && !w->isMinimized())
if (w != widget && w->isWindow() && w->isVisible() && !w->isMinimized())
candidates << w;
if (QDockWidgetGroupWindow *group = qobject_cast<QDockWidgetGroupWindow *>(w)) {
// Sometimes, there are floating QDockWidget that have a QDockWidgetGroupWindow as a parent.