Important: Please read the Qt Code of Conduct -

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

  • 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();
    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";

    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?

  • 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.

  • Moderators

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

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

Log in to reply