Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved]Can't load the image after I register the qml file to Qt resource system
QtWS25 Last Chance

[Solved]Can't load the image after I register the qml file to Qt resource system

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 7.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    Before I register the main.qml to Qt resource system, everything are fine
    after I register the main.qml to Qt resource system, I can't open the file

    main.qml
    @
    import QtQuick 2.0

    Rectangle {
    width: 360
    height: 360

    Image{
        anchors.fill: parent
        source: "/Pictures/img_0000.jpg"
    }
    

    }
    @

    main.cpp
    @
    #include <QtGui/QGuiApplication>
    #include "qtquick2applicationviewer.h"

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    //viewer.setMainQmlFile&#40;QStringLiteral("qml/qmlResource/main.qml"&#41;&#41;;
    viewer.setSource(QStringLiteral("qrc:///qml/qmlResource/main.qml"));
    viewer.showExpanded();
    
    return app.exec&#40;&#41;;
    

    }
    @

    error message

    qrc:///qml/qmlResource/main.qml:7:5: QML Image: Cannot open: qrc:///Pictures/img_0000.jpg

    looks like the Image complain it can not find the image from qrc
    but I don't want the program to load the image from qrc
    it is not my intention

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stereomatching
      wrote on last edited by
      #2

      find the answer
      "solution":http://qt-project.org/forums/viewthread/10477

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved