QPixmap not show in .exe file
-
hi. i use this code to showing pixmap:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); QPixmap pm(":/img/board/tic.jpg"); ui->board->setScaledContents(true); ui->board->setPixmap(pm); }this code work when i run my app in release mode in qtcreator but in release folder when i click on .exe file its dont work and this code dont showing the picture.
but when i use the directory of my img(like this: C://dir/dir/...) its showing my picture.sorry if im not good in english. please help!
-
How do you deploy your executable? Use windeployqt - it deploys all required plugins (in your case the jpg image plugin).
-
How do you deploy your executable? Use windeployqt - it deploys all required plugins (in your case the jpg image plugin).
@Christian-Ehrlicher i use this command :
windeployqt.exe --quick . -
i dont think my problem is from deploy becuse when i use this code its showing my picture:
QPixmap pm("C:/Users/Other/Desktop/img1.jpg"); ui->board->setScaledContents(true); ui->board->setPixmap(pm);i think my problem is from loading picture in recourse file in my project
-
@Christian-Ehrlicher i use this command :
windeployqt.exe --quick .@iliahero
In your code put inqDebug() << QFile::exists(":/img/board/tic.jpg");(or whatever suitable in place ofqDebug()). That tells you whether the file exists. Assuming that returns true the issue is with showing the pixmap, maybe as @Christian-Ehrlicher said; if it returns false you have some other problem. -
@iliahero
In your code put inqDebug() << QFile::exists(":/img/board/tic.jpg");(or whatever suitable in place ofqDebug()). That tells you whether the file exists. Assuming that returns true the issue is with showing the pixmap, maybe as @Christian-Ehrlicher said; if it returns false you have some other problem. -
@iliahero
So as @Christian-Ehrlicher says it looks like the deployed version has trouble showing a.jpgfile. Look in whatwindeployqthas packaged for your executable, does it contain anything like a plugin to do with showing JPEGs?@JonB
i use this command :
windeployqt.exe --quick .my release folder have a folder named imgformats its have :
qgif, gicn, qico, qjpeg, qsvg, qtgs, qtiff, qwbmp, qwebm.but as i said i think the problem is not from deploy becuse when i use the path of my img in my desktop and deploy my project its showing pixmap
-
Maybe it's a confusion/mixup of filenames, you have
":/img/board/tic.jpg" and C:/Users/Other/Desktop/img1.jpg, not the same file?@hskoglund my problem solved
thanks
-
@JonB
i use this command :
windeployqt.exe --quick .my release folder have a folder named imgformats its have :
qgif, gicn, qico, qjpeg, qsvg, qtgs, qtiff, qwbmp, qwebm.but as i said i think the problem is not from deploy becuse when i use the path of my img in my desktop and deploy my project its showing pixmap
@iliahero
Yes, I understand it is weird if it works from an external.jpgfile but not from one in a resource which you have checked exists. I do not have an explanation for that.Unless somehow the resource image does not contain what you think it does.
-
Get rid of
setScaledContents()just in case that is a problem. -
Discover whether on the line after
QPixmap pm("C:/Users/Other/Desktop/img1.jpg");thatqDebug() << pm.isNull();returns true or false. -
For the sake of a few minutes coding, try in your code extracting
:/img/board/tic.jpgto an external file and then setting that as a pixmap. Look at the extracted file and see if it is correct.
-