Results 1 to 8 of 8

Thread: Where have all the icons gone?

  1. #1
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    121
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Where have all the icons gone?

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Where have all the icons gone?

    It's likely you forgot to tell your project file about the resource file (RESOURCES+=file.qrc)
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    121
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Where have all the icons gone?

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Where have all the icons gone?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    121
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Where have all the icons gone?

    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)
    Last edited by gib; 6th September 2010 at 07:53.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Where have all the icons gone?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    121
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Where have all the icons gone?

    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.
    Last edited by gib; 6th September 2010 at 08:19.

  8. #8
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    121
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Where have all the icons gone?

    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.

Similar Threads

  1. QT QListView (as icons)
    By Majdi in forum Newbie
    Replies: 10
    Last Post: 2nd March 2010, 23:22
  2. Icons in a QListWidget
    By LuHe in forum Qt Tools
    Replies: 10
    Last Post: 30th January 2010, 04:19
  3. How do compare the two icons
    By addu in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2009, 16:19
  4. Where to get Icons from
    By pospiech in forum General Discussion
    Replies: 4
    Last Post: 19th December 2008, 21:14
  5. Loading SVG icons
    By user_mail07 in forum Qt Programming
    Replies: 2
    Last Post: 28th June 2007, 04:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.