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 QDeclarativeView with QML source that references other QML files
QtWS25 Last Chance

[SOLVED] Can't load QDeclarativeView with QML source that references other QML files

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.2k 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.
  • F Offline
    F Offline
    frankiefrank
    wrote on last edited by
    #1

    I use QDeclarativeView in a C++ application and load a QML file from the file system like this:

    @

        mView = new QDeclarativeView(this);
    

    mEngine = mView->engine();
    mContext = mEngine->rootContext();
    mView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    for (int i = 0; i < mView->errors().count(); i++)
    {
    QDeclarativeError currError = mView->errors().at(i);
    QString desc = currError.description();
    int line = currError.line();
    }

    QString filePath = "D:\QmlTest\QmlTest.qml";
    mView->setSource(filePath);
    @

    The QML references another QML from the same directory: called ActionButton.qml.
    When I load the QML file in a QtCreator project (containing the QML only), it works with the referenced file. But in my C++ application project loaded in Visual Studio (using the above code) the file fails to load as soon as the ActionButton references appear.

    I can't really figure out why OR how to see the relevant errors. What am I missing?

    "Roads? Where we're going, we don't need roads."

    1 Reply Last reply
    0
    • F Offline
      F Offline
      frankiefrank
      wrote on last edited by
      #2

      Ok hope no one is getting tired from me solving my own issues :-)

      Looks like it works if I use QUrl::fromLocalFile() instead of just sending a QString.

      "Roads? Where we're going, we don't need roads."

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #3

        [quote author="frankiefrank" date="1317642487"]Ok hope no one is getting tired from me solving my own issues :-)
        [/quote]

        Glad you were able to figure it out! :-) Be sure and edit your thread title to add [Solved] (regardless of who solved it!)

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        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