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. Issue using QQuickWidget with a resource qml file in a plugin
QtWS25 Last Chance

Issue using QQuickWidget with a resource qml file in a plugin

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 629 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.
  • xavi-bX Offline
    xavi-bX Offline
    xavi-b
    wrote on last edited by xavi-b
    #1

    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):

    this->setSource(QUrl(":/qml/MyQmlFile.qml"));
    

    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"));
    file.open(QIODevice::ReadOnly); // 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 ?

    1 Reply Last reply
    0
    • xavi-bX Offline
      xavi-bX Offline
      xavi-b
      wrote on last edited by
      #2

      Solution is to use:

      this->setSource(QUrl("qrc:/qml/MyQmlFile.qml"));
      

      QUrl apparently needs qrc:/ and not just :/

      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