Results 1 to 9 of 9

Thread: qrc resources are not available during debug build

  1. #1
    Join Date
    Dec 2012
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default qrc resources are not available during debug build

    Qt 5.0 windows

    debug build of my program can't load png image from resources. Widget that supposed to show it stays empty. But when i switch to Release build the image appears just fine.
    Also when I use direct path like "c://image.png" then it works too.

    I did not modify any build parameters and got fresh installation of Qt 5.0.

    do i need to add something to my project settings?

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

    Default Re: qrc resources are not available during debug build

    Please prepare a minimal compilable example reproducing the problem.
    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
    Dec 2012
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qrc resources are not available during debug build

    main.cpp

    Qt Code:
    1. #include <QApplication>
    2. #include <QGraphicsScene>
    3. #include <QGraphicsView>
    4. #include <QGraphicsPixmapItem>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8.  
    9. QApplication a(argc, argv);
    10. QGraphicsView view(&scene);
    11. QGraphicsPixmapItem item(QPixmap(":/images/wearepros.png")); //doesn't load during debug build
    12. scene.addItem(&item);
    13. view.show();
    14. return a.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

    res.qrc
    Qt Code:
    1. <RCC>
    2. <qresource prefix="/images">
    3. <file>sample.jpg</file>
    4. <file>wearepros.png</file>
    5. <file>sample.bmp</file>
    6. </qresource>
    7. </RCC>
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: qrc resources are not available during debug build

    What about the project file?
    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
    Dec 2012
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qrc resources are not available during debug build

    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2012-12-23T13:46:35
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = test3
    12. TEMPLATE = app
    13.  
    14.  
    15. SOURCES += main.cpp\
    16. mainwindow.cpp
    17.  
    18. HEADERS += mainwindow.h
    19.  
    20. FORMS += mainwindow.ui
    21.  
    22. RESOURCES += \
    23. res.qrc
    To copy to clipboard, switch view to plain text mode 

    I created project via New Project->Qt gui project. Then replaced main.cpp with my code and left everything else as it was. then did Add new ->qt resource, added prefix and files.


    Added after 7 minutes:


    I uploaded my project's folder if you like
    http://rghost.net/42458531
    Last edited by roumor; 23rd December 2012 at 16:54.

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

    Default Re: qrc resources are not available during debug build

    The code looks ok and it works fine for me both in release and debug (on Linux though, however this shouldn't matter).

    Please check if the final size of your debug executable changes depending on whether RESOURCES += res.qrc exists in your project file or not.
    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
    Dec 2012
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qrc resources are not available during debug build

    Nope it does not change. it always stays 56kb

    release one does change. it is 11kb without "RESOURCES +=" line in pro and 275kb with it.

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

    Default Re: qrc resources are not available during debug build

    Quote Originally Posted by roumor View Post
    Nope it does not change. it always stays 56kb
    Try cleaning the project completely, run qmake and make again. Do you get any warnings during compilation?
    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.


  9. #9
    Join Date
    Dec 2012
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qrc resources are not available during debug build

    thank you wysota.

    I re installed Qt completely and it's now working and showing resources.

Similar Threads

  1. Qt + Linux + Eclipse - debug using debug build?
    By will49 in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2012, 07:27
  2. debug build
    By sajis997 in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2012, 07:21
  3. Replies: 2
    Last Post: 4th October 2011, 00:04
  4. DEBUG macro not defined in debug build using vc++
    By piotr.dobrogost in forum Qt Programming
    Replies: 0
    Last Post: 21st July 2009, 14:07
  5. Replies: 3
    Last Post: 28th December 2007, 12:02

Tags for this Thread

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.