Important: Please read the Qt Code of Conduct -

Not displaying image in the window

  • the source code
    @QPalette p = palette();
    QPixmap pixmap1(":/new/prefix1/BG");

        QDesktopWidget* desktopWidget = QApplication::desktop();
        QRect rect = desktopWidget->availableGeometry();
        QSize size(rect.width() , rect.height());
        QPixmap pixmap(pixmap1.scaled(size));
        p.setBrush(QPalette::Background,  pixmap);
        setPalette(p);@ when the project is built in the output console it displays--QPixmap::scaled: Pixmap is a null pixmap

  • BG without extension?

  • So, is the image actually in the resource? Did you deploy the needed image format plugin?

  • yeah, like stuk said; you may have mis-typed the filename :)

    Also would like to suggest you use QImage for opening the image which is much faster than using a pixmap for nothing but scaling.

  • I think you should replace
    QPixmap pixmap1(":/new/prefix1/BG");
    QPixmap pixmap1(":/new/prefix1/BG.png");
    QPixmap pixmap1(":/new/prefix1/BG.jpg");

    you need to put the image extension in the code.

Log in to reply