Avoid using deprecated API in the icons example

Fixes compilation warning.

Fixes: QTBUG-100155
Change-Id: I1af2e69c070497509645c933df58fd42277cfb18
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Eirik Aavitsland 2022-02-07 17:36:33 +01:00
parent 4cca8ee527
commit 51ff94ec92
1 changed files with 3 additions and 5 deletions

View File

@ -52,6 +52,7 @@
#include <QGridLayout>
#include <QLabel>
#include <QWindow>
//! [0]
IconPreviewArea::IconPreviewArea(QWidget *parent)
@ -152,14 +153,11 @@ QLabel *IconPreviewArea::createPixmapLabel()
//! [5]
void IconPreviewArea::updatePixmapLabels()
{
QWindow *window = nullptr;
if (const QWidget *nativeParent = nativeParentWidget())
window = nativeParent->windowHandle();
for (int column = 0; column < NumModes; ++column) {
for (int row = 0; row < NumStates; ++row) {
const QPixmap pixmap =
icon.pixmap(window, size, IconPreviewArea::iconModes().at(column),
IconPreviewArea::iconStates().at(row));
icon.pixmap(size, devicePixelRatio(), IconPreviewArea::iconModes().at(column),
IconPreviewArea::iconStates().at(row));
QLabel *pixmapLabel = pixmapLabels[column][row];
pixmapLabel->setPixmap(pixmap);
pixmapLabel->setEnabled(!pixmap.isNull());