Image & release problem
-
Hi,
I've been using QT for several years, but have just changed to the latest. I was using something like QT 5.6. Now its QT creator 14.0.0 based on QT 6.7.2
However I'm having a couple of problems that I hope someone can help me with.
In the older version I displayed some images in QPushButtons, but now they only seem to work on a debug build and not on a release one.
this is a copy of the code I have from a simple app.
string im = "C:/some path/some filename.jpg"; QImage qim(im.c_str()); bool bim = qim.isNull(); QPixmap pix (im.c_str()); QIcon buttonIcon(pix); QSize iconSize; int w = 60; int h = 30; iconSize.setWidth(w); iconSize.setHeight(h); bool bp = pix.isNull(); bool bi = buttonIcon.isNull(); ui->pushButton_2->setIcon(buttonIcon); ui->pushButton_2->setIconSize(iconSize);but as farf as I can tell in the release runs all the images are null. i.e. bim, bp and bi are all true.
in a debug run they all seem to work fine. I've tried with a gif file as well as a jpg and that has the same problem.
It could be something to do with how it's started I guess. i.e. I build it in qt creator and get the results above when I run from inside qtcreator, and if I just try running the exe directly I get the images are null failures in both the debug and release build.
A similar issue I now have is that if I try to run my apps they seem to need a bunch of dlls in the same directory which they never needed before. (like QT6Gui.dll)
-
Hi,
I've been using QT for several years, but have just changed to the latest. I was using something like QT 5.6. Now its QT creator 14.0.0 based on QT 6.7.2
However I'm having a couple of problems that I hope someone can help me with.
In the older version I displayed some images in QPushButtons, but now they only seem to work on a debug build and not on a release one.
this is a copy of the code I have from a simple app.
string im = "C:/some path/some filename.jpg"; QImage qim(im.c_str()); bool bim = qim.isNull(); QPixmap pix (im.c_str()); QIcon buttonIcon(pix); QSize iconSize; int w = 60; int h = 30; iconSize.setWidth(w); iconSize.setHeight(h); bool bp = pix.isNull(); bool bi = buttonIcon.isNull(); ui->pushButton_2->setIcon(buttonIcon); ui->pushButton_2->setIconSize(iconSize);but as farf as I can tell in the release runs all the images are null. i.e. bim, bp and bi are all true.
in a debug run they all seem to work fine. I've tried with a gif file as well as a jpg and that has the same problem.
It could be something to do with how it's started I guess. i.e. I build it in qt creator and get the results above when I run from inside qtcreator, and if I just try running the exe directly I get the images are null failures in both the debug and release build.
A similar issue I now have is that if I try to run my apps they seem to need a bunch of dlls in the same directory which they never needed before. (like QT6Gui.dll)
@tjl34567 said in Image & release problem:
It could be something to do with how it's started I guess. i.e. I build it in qt creator and get the results above when I run from inside qtcreator, and if I just try running the exe directly I get the images are null failures in both the debug and release build.
Your code
string im = "C:/some path/some filename.jpg";implies you are using an absolute path. Is that really the case? Behaviour would not be unexpected if you use a relative path here, as that relies on the current working directory which may not be the same inside vs outside Creator.Might be related for DLLs. They must be found either in the current directory or same as executable (can't recall which, might be the latter) or on the
PATH. -
yes I put in the complete path just to try to make sure it was working correctly. Really I will start from the exe location and navigate to the images folder, but I just need it make something work first
I think I've set up PATH - I added ;C:\Qt\Tools\QtCreator\bin to it which is where I found the dll's it said I was missing, but that doesn't seem to help. It all feels odd. I'm almost sure on the old version I had something similar, but certainly not under qtcreator. maybe c:\qt\5.6\bin
-
Hi,
On which version of Windows are you working ?
By the way, why not use QString for your paths rather than doing these conversions ? -
windows 10 home on this laptop - and literally a new one has just arrived using windows 11.
I just prefer string to QString - no real reason, just using the same one all the time just means I know where I am (forever adding .c_str() to convert for QT functions :-)
If its even vaguely possibly causing a problem I could try changing it -
Hi,
I've been using QT for several years, but have just changed to the latest. I was using something like QT 5.6. Now its QT creator 14.0.0 based on QT 6.7.2
However I'm having a couple of problems that I hope someone can help me with.
In the older version I displayed some images in QPushButtons, but now they only seem to work on a debug build and not on a release one.
this is a copy of the code I have from a simple app.
string im = "C:/some path/some filename.jpg"; QImage qim(im.c_str()); bool bim = qim.isNull(); QPixmap pix (im.c_str()); QIcon buttonIcon(pix); QSize iconSize; int w = 60; int h = 30; iconSize.setWidth(w); iconSize.setHeight(h); bool bp = pix.isNull(); bool bi = buttonIcon.isNull(); ui->pushButton_2->setIcon(buttonIcon); ui->pushButton_2->setIconSize(iconSize);but as farf as I can tell in the release runs all the images are null. i.e. bim, bp and bi are all true.
in a debug run they all seem to work fine. I've tried with a gif file as well as a jpg and that has the same problem.
It could be something to do with how it's started I guess. i.e. I build it in qt creator and get the results above when I run from inside qtcreator, and if I just try running the exe directly I get the images are null failures in both the debug and release build.
A similar issue I now have is that if I try to run my apps they seem to need a bunch of dlls in the same directory which they never needed before. (like QT6Gui.dll)
@tjl34567 seems like you did the release/deployment mechanism by hand, depending on the error popup you get when launching the exe instead of using the provided proper tools.
you're almost certainly missing the "imageformats" folder and the required dlls, such as: qjpeg.dll qpng.dll besides other stuff
you should use the windows deployment tool:
https://doc.qt.io/qt-6/windows-deployment.html