PDA

View Full Version : Where have all the icons gone?



gib
6th September 2010, 07:09
I've just been porting my Qt application from Windows XP/MS Visual Studio to Windows 7/MinGW/QtCreator. The Qt version has gone from 4.6.2 to 4.6.3. Everything is working well, except that my icons refuse to display. I have 7 .png files that I use as button icons in my resources file (icons.qrc), and when I open the form in Designer I can see them, and everything seems correct (as far as I can tell). But when I build the application with QtCreator and run it they are nowhere in sight.

I have to confess that my understanding of Resources is very sketchy, but I was able to get it them to build properly when using MS Visual Studio. What am I likely to be doing wrong? Thanks for help - I've wasted a couple of hours on this going around in circles. :(

Gib

wysota
6th September 2010, 07:19
It's likely you forgot to tell your project file about the resource file (RESOURCES+=file.qrc)

gib
6th September 2010, 07:35
I could have forgotten that, but I didn't. I see the .qrc file in the file list in QtCreator, and when I double-click on it I see all the icons. It is very strange.

wysota
6th September 2010, 07:41
Forget QtCreator. Open the .pro file and see what's in there. Also make sure if you have appropriate imageformat plugins deployed if you are using icon formats other than png.

gib
6th September 2010, 07:48
Yes, I have looked in the .pro file, and it contains
RESOURCES += icons.qrc
I've also tried building from the command line, with qmake then make. No difference.
The icon formats are all png.
I've also looked in the .h file that uic creates from the .ui file, and I see sections like
QIcon icon1;
icon1.addFile(QString::fromUtf8(":/icons/001_29.png"), QSize(), QIcon::Normal, QIcon::Off);
action_stop->setIcon(icon1);
action_run = new QAction(MainWindow);
action_run->setObjectName(QString::fromUtf8("action_run"));
Does this look OK?
(BTW thanks for responding)

wysota
6th September 2010, 07:56
Yes, it looks ok. From the console run make distclean, rerun qmake and see if you get any warnings. If you do, post them here. If not, continue with make. Then note the size of the resulting binary and repeat the process after commenting out the "RESOURCES += icons.qrc" line from your .pro file. Compare binary sizes and see if they differ.

gib
6th September 2010, 08:12
The make distclean output was:

C:\Users\Gib\ABM_GUI>make distclean
c:\Qt\4.6.3\bin\qmake.exe -win32 -o Makefile ABM_GUI.pro
mingw32-make -f Makefile.Release distclean
mingw32-make[1]: Entering directory `C:/Users/Gib/ABM_GUI'
del release\moc_mainwindow.cpp release\moc_qmylabel.cpp release\moc_misc.cpp
del ui_ABM_GUI.h
del release\main.o release\mainwindow.o release\params.o release\plot.o release\
myvtk.o release\misc.o release\lognormal.o release\moc_mainwindow.o release\moc_
qmylabel.o release\moc_misc.o
del release\ABM_GUI.exe
del Makefile.Release
mingw32-make[1]: Leaving directory `C:/Users/Gib/ABM_GUI'
mingw32-make -f Makefile.Debug distclean
mingw32-make[1]: Entering directory `C:/Users/Gib/ABM_GUI'
del debug\moc_mainwindow.cpp debug\moc_qmylabel.cpp debug\moc_misc.cpp
Could Not Find C:\Users\Gib\ABM_GUI\debug\moc_mainwindow.cpp
del ui_ABM_GUI.h
Could Not Find C:\Users\Gib\ABM_GUI\ui_ABM_GUI.h
del debug\main.o debug\mainwindow.o debug\params.o debug\plot.o debug\myvtk.o de
bug\misc.o debug\lognormal.o debug\moc_mainwindow.o debug\moc_qmylabel.o debug\m
oc_misc.o
Could Not Find C:\Users\Gib\ABM_GUI\debug\main.o
del debug\ABM_GUI.exe
Could Not Find C:\Users\Gib\ABM_GUI\debug\ABM_GUI.exe
del Makefile.Debug
mingw32-make[1]: Leaving directory `C:/Users/Gib/ABM_GUI'
del Makefile

qmake generates no output to the console.

The binary with and without icons.qrc is the same size 745984 bytes.

make generates a lot of warnings, about some deprecated coding practices.

gib
6th September 2010, 08:19
I just found my stupid mistake!!

For some reason, later in the .pro file than the 'RESOURCES += icons.qrc', I had the line
RESOURCES =
I can only guess that I was interrupted or distracted while making a change.

Sorry for wasting your time, and thanks for pointing me in the right direction.