Fix qtbase build when all deprecated code are disabled

Adjust the callers to use the non-deprecated APIs.

Pick-to: 6.5
Change-Id: I8e96f25684a2d613bc400a8626dc9e3af2bb8dcf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Yuhang Zhao 2023-02-20 17:06:46 +08:00
parent b4b4c81401
commit f7fd5eaf95
8 changed files with 16 additions and 16 deletions

View File

@ -62,7 +62,7 @@ void Screenshot::resizeEvent(QResizeEvent * /* event */)
{ {
QSize scaledSize = originalPixmap.size(); QSize scaledSize = originalPixmap.size();
scaledSize.scale(screenshotLabel->size(), Qt::KeepAspectRatio); scaledSize.scale(screenshotLabel->size(), Qt::KeepAspectRatio);
if (scaledSize != screenshotLabel->pixmap(Qt::ReturnByValue).size()) if (scaledSize != screenshotLabel->pixmap().size())
updateScreenshotLabel(); updateScreenshotLabel();
} }
//! [1] //! [1]

View File

@ -151,8 +151,8 @@
will expand to will expand to
\code \code
if (imageLabel->pixmap(Qt::ReturnByValue).isNull()) if (imageLabel->pixmap().isNull())
qFatal("ASSERT: "imageLabel->pixmap(Qt::ReturnByValue).isNull()" in file ..."); qFatal("ASSERT: "imageLabel->pixmap().isNull()" in file ...");
\endcode \endcode
In release mode, the macro simply disappear. The mode can be set In release mode, the macro simply disappear. The mode can be set

View File

@ -95,7 +95,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
if (!child) if (!child)
return; return;
QPixmap pixmap = child->pixmap(Qt::ReturnByValue); QPixmap pixmap = child->pixmap();
QByteArray itemData; QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly); QDataStream dataStream(&itemData, QIODevice::WriteOnly);

View File

@ -161,7 +161,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
//! [16] //! [16]
QDrag *drag = new QDrag(this); QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData); drag->setMimeData(mimeData);
drag->setPixmap(child->pixmap(Qt::ReturnByValue)); drag->setPixmap(child->pixmap());
drag->setHotSpot(hotSpot); drag->setHotSpot(hotSpot);
child->hide(); child->hide();

View File

@ -158,14 +158,14 @@ void ImageViewer::saveAs()
void ImageViewer::print() void ImageViewer::print()
//! [5] //! [6] //! [5] //! [6]
{ {
Q_ASSERT(!imageLabel->pixmap(Qt::ReturnByValue).isNull()); Q_ASSERT(!imageLabel->pixmap().isNull());
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) #if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
//! [6] //! [7] //! [6] //! [7]
QPrintDialog dialog(&printer, this); QPrintDialog dialog(&printer, this);
//! [7] //! [8] //! [7] //! [8]
if (dialog.exec()) { if (dialog.exec()) {
QPainter painter(&printer); QPainter painter(&printer);
QPixmap pixmap = imageLabel->pixmap(Qt::ReturnByValue); QPixmap pixmap = imageLabel->pixmap();
QRect rect = painter.viewport(); QRect rect = painter.viewport();
QSize size = pixmap.size(); QSize size = pixmap.size();
size.scale(rect.size(), Qt::KeepAspectRatio); size.scale(rect.size(), Qt::KeepAspectRatio);
@ -343,7 +343,7 @@ void ImageViewer::scaleImage(double factor)
//! [23] //! [24] //! [23] //! [24]
{ {
scaleFactor *= factor; scaleFactor *= factor;
imageLabel->resize(scaleFactor * imageLabel->pixmap(Qt::ReturnByValue).size()); imageLabel->resize(scaleFactor * imageLabel->pixmap().size());
adjustScrollBar(scrollArea->horizontalScrollBar(), factor); adjustScrollBar(scrollArea->horizontalScrollBar(), factor);
adjustScrollBar(scrollArea->verticalScrollBar(), factor); adjustScrollBar(scrollArea->verticalScrollBar(), factor);

View File

@ -403,10 +403,10 @@ QAccessible::Role QAccessibleDisplay::role() const
#if QT_CONFIG(label) #if QT_CONFIG(label)
QLabel *l = qobject_cast<QLabel*>(object()); QLabel *l = qobject_cast<QLabel*>(object());
if (l) { if (l) {
if (!l->pixmap(Qt::ReturnByValue).isNull()) if (!l->pixmap().isNull())
return QAccessible::Graphic; return QAccessible::Graphic;
#ifndef QT_NO_PICTURE #ifndef QT_NO_PICTURE
if (!l->picture(Qt::ReturnByValue).isNull()) if (!l->picture().isNull())
return QAccessible::Graphic; return QAccessible::Graphic;
#endif #endif
#if QT_CONFIG(movie) #if QT_CONFIG(movie)
@ -531,7 +531,7 @@ QSize QAccessibleDisplay::imageSize() const
#endif #endif
return QSize(); return QSize();
#if QT_CONFIG(label) #if QT_CONFIG(label)
return label->pixmap(Qt::ReturnByValue).size(); return label->pixmap().size();
#endif #endif
} }
@ -544,7 +544,7 @@ QPoint QAccessibleDisplay::imagePosition() const
#endif #endif
return QPoint(); return QPoint();
#if QT_CONFIG(label) #if QT_CONFIG(label)
if (label->pixmap(Qt::ReturnByValue).isNull()) if (label->pixmap().isNull())
return QPoint(); return QPoint();
return QPoint(label->mapToGlobal(label->pos())); return QPoint(label->mapToGlobal(label->pos()));

View File

@ -272,7 +272,7 @@ void QMessageBoxPrivate::setupLayout()
Q_Q(QMessageBox); Q_Q(QMessageBox);
delete q->layout(); delete q->layout();
QGridLayout *grid = new QGridLayout; QGridLayout *grid = new QGridLayout;
bool hasIcon = !iconLabel->pixmap(Qt::ReturnByValue).isNull(); const bool hasIcon = !iconLabel->pixmap().isNull();
if (hasIcon) if (hasIcon)
grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop); grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop);
@ -1329,7 +1329,7 @@ void QMessageBox::setIcon(Icon icon)
QPixmap QMessageBox::iconPixmap() const QPixmap QMessageBox::iconPixmap() const
{ {
Q_D(const QMessageBox); Q_D(const QMessageBox);
return d->iconLabel->pixmap(Qt::ReturnByValue); return d->iconLabel->pixmap();
} }
void QMessageBox::setIconPixmap(const QPixmap &pixmap) void QMessageBox::setIconPixmap(const QPixmap &pixmap)

View File

@ -414,8 +414,8 @@ public:
} }
QSize minimumSizeHint() const override { QSize minimumSizeHint() const override {
if (!pixmap(Qt::ReturnByValue).isNull()) if (!pixmap().isNull())
return pixmap(Qt::ReturnByValue).deviceIndependentSize().toSize(); return pixmap().deviceIndependentSize().toSize();
return QFrame::minimumSizeHint(); return QFrame::minimumSizeHint();
} }