Results 1 to 2 of 2

Thread: Image resource lookup in OS X

  1. #1
    Join Date
    Nov 2010
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Windows Symbian S60

    Default Image resource lookup in OS X

    Hi,

    I've created new QtQuick application with latest Qt SDK for OS X and with lastest Qt Creator.

    I have image lol.png, located in /images dir under project root dir.

    I have resource file:
    Qt Code:
    1. <RCC>
    2. <qresource prefix="/images">
    3. <file>images/lol.png</file>
    4. </qresource>
    5. </RCC>
    To copy to clipboard, switch view to plain text mode 

    project file:
    Qt Code:
    1. RESOURCES += \
    2. qui.qrc
    To copy to clipboard, switch view to plain text mode 

    and main.qml:
    Qt Code:
    1. Image {
    2. source: ":/images/images/lol.png"
    3. }
    To copy to clipboard, switch view to plain text mode 

    However, when I run project, I got error message:
    file:///xxxxxxxxx/qui-build-desktop/qui.app/Contents/Resources/qml/qui/main.qml:8:5: QML Image: Cannot open: file:///images/images/lol.png
    When I use same resource scheme and try to load resource in main.cpp, everything works fine.
    Qt Code:
    1. QImage* i = new QImage(":/images/images/lol.png");
    2. qDebug() << i->width();
    To copy to clipboard, switch view to plain text mode 

    I checked output build directory, ../qui-build-desktop, there is file qrc_qui.cpp, that contains my image resource, with comments containing scheme from above.

    My question is - why resource cannot be loaded from qml?

    Thanks,

    -Lev
    Last edited by stipa; 30th November 2010 at 00:46.

  2. #2
    Join Date
    Dec 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Image resource lookup in OS X

    try this:

    Image {
    source: "qrc:/images/images/lol.png"
    }

Similar Threads

  1. How can Stylesheet reference non resource image file
    By dpatel in forum Qt Programming
    Replies: 1
    Last Post: 23rd April 2010, 09:41
  2. QPainter.drawImage() not working with resource image file
    By thiagoalencar22 in forum Qt Programming
    Replies: 4
    Last Post: 22nd April 2010, 22:07
  3. QTextDocument Image resource problem
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 16:28
  4. Dynamic lookup problem
    By jwintz in forum Qt Programming
    Replies: 3
    Last Post: 30th May 2006, 15:19
  5. lookup table
    By georgie in forum General Programming
    Replies: 6
    Last Post: 12th May 2006, 10:57

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.