[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();
    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?



  • 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 :-)
    [/quote]

    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.