Important: Please read the Qt Code of Conduct -

Issue using QQuickWidget with a resource qml file in a plugin

  • Hi,

    I'm currently developing an application loading several plugins (based on Qt plugins documentation).
    Each plugin is creating a widget with a function like this one:

    QWidget* createWidget();

    Everything worked fine and widgets were created and displayed until I decided to.. return a QQuickWidget !
    I set its source to a qml file in a resource file (with a different name from other plugins' resource files to avoid conflict):


    and the widget returned an error (when loaded in the main application): "file:///path/to/my/app/executable/: file to open is a directory"

    Futher information:

    QFile file(QUrl(":/qml/MyQmlFile.qml"));; // returns true
    this->setSource(QUrl("/path/to/my/plugin/qml/MyQmlFile.qml")); // works fine

    Any ideas why QQuickWidget won't load my qml file when in a resource file ?

  • Solution is to use:


    QUrl apparently needs qrc:/ and not just :/

Log in to reply