Not displaying image in the window
General and Desktop
5
Posts
5
Posters
1.6k
Views
1
Watching
-
wrote on 5 Feb 2013, 09:44 last edited by
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
-
wrote on 5 Feb 2013, 10:03 last edited by
BG without extension?
-
wrote on 5 Feb 2013, 10:04 last edited by
So, is the image actually in the resource? Did you deploy the needed image format plugin?
-
wrote on 5 Feb 2013, 10:06 last edited by
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.
-
wrote on 5 Feb 2013, 11:13 last edited by
I think you should replace
QPixmap pixmap1(":/new/prefix1/BG");
for
QPixmap pixmap1(":/new/prefix1/BG.png");
or
QPixmap pixmap1(":/new/prefix1/BG.jpg");you need to put the image extension in the code.
1/5