Results 1 to 2 of 2

Thread: qmlscene and resources

  1. #1
    Join Date
    Nov 2014
    Posts
    33
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows Android

    Default qmlscene and resources

    I've an image, gps.png, that is included in a resource.

    The image is in the resources/images/ directory.

    The resource file has this entry:

    Qt Code:
    1. <qresource prefix="/images">
    2. <file alias="gps">resources/images/gps.png</file>
    3. </qresource>
    To copy to clipboard, switch view to plain text mode 

    On qml, has this code:

    Qt Code:
    1. Image {
    2. width: 64
    3. height: 64
    4. source: "images/gps"
    5. }
    To copy to clipboard, switch view to plain text mode 

    If I run this program, it works well, the image appears, but if I run qmlscene, nothing appears, it doesn't find the image. Only appears when I put the complete path: resources/images/gps.png.

    How can I prototype using qmlscene when use resources?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qmlscene and resources

    Resources are binary data that is built into the program or library, i.e. it is basically part of the C++ part of the application.

    Since you don't use a resource URI in your QML, the easiest way is make sure that the relative paths inside the resource match the relative paths, so "source" URLs are always just the same relative filename.

    That even helps a lot when testing the actual C++ application: changes to files on disk can be made available to the running program by reloading.

    Cheers,
    _

Similar Threads

  1. Is it possible to add QT resources to a DLL?
    By cboles in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2017, 01:12
  2. Portable qt5.4 but "no qmlscene installed"
    By manceb in forum Installation and Deployment
    Replies: 2
    Last Post: 16th April 2016, 23:01
  3. qmlscene dummydata
    By lqsa in forum Qt Tools
    Replies: 10
    Last Post: 2nd August 2015, 16:15
  4. MP3 file from Resources :-/
    By qtpat in forum Qt Programming
    Replies: 5
    Last Post: 26th March 2014, 17:34
  5. Qt Resources
    By kaushal_gaurav in forum Qt Programming
    Replies: 3
    Last Post: 3rd October 2008, 17:30

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.