Results 1 to 8 of 8

Thread: Loading a qmldir from a qrc file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2011
    Location
    Canada
    Posts
    8
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Loading a qmldir from a qrc file

    did you try:

    Qt Code:
    1. import "qrc:/content/";
    2. import SkyComponents 1.0;
    To copy to clipboard, switch view to plain text mode 

    i tested this on my side, it appears to work as expected:

    Qt Code:
    1. import QtQuick 1.0;
    2. import 'qrc:/builtin/qml/';
    3. import 'qrc:/builtin/js/netsh.js' as Netsh;
    4.  
    5. FrameDark {
    6. id: btnLoginText
    7. width: 150
    8. height: 32
    9. text: "Connect"
    10. anchors.bottom: parent.bottom
    11. anchors.bottomMargin: 0
    12. anchors.horizontalCenter: parent.horizontalCenter
    13. onClicked: { Netsh.loginClicked(); }
    14. }
    To copy to clipboard, switch view to plain text mode 

    actually, i should probably also provide this:

    my qrc:
    Qt Code:
    1. <RCC>
    2. <qresource prefix="/builtin">
    3. <file alias="js/netsh.js">../js/netsh.js</file>
    4. <file alias="qml/qmldir">../qml/qmldir</file>
    5. <file alias="qml/FrameDark.qml">../qml/FrameDark.qml</file>
    6. <file alias="images/FrameDark/FrameDark.png">../images/FrameDark/FrameDark.png</file>
    7. <file alias="images/FrameDark/FrameDarkA.png">../images/FrameDark/FrameDarkA.png</file>
    8. </qresource>
    9. </RCC>
    To copy to clipboard, switch view to plain text mode 

    and the qmldir (brace yourself, it's VERY LONG):
    Qt Code:
    1. FrameDark FrameDark.qml
    To copy to clipboard, switch view to plain text mode 

    and that QML import tracing envvar doodad shows:

    Qt Code:
    1. QDeclarativeImports(file::/builtin/qml/rrcbs/login.qml)::addImport: "." -1.-1 File as ""
    2. QDeclarativeImports(file::/builtin/qml/rrcbs/login.qml)::addImport: "QtQuick" 1.0 Library as ""
    3. QDeclarativeImports(file::/builtin/qml/rrcbs/login.qml)::addImport: "qrc:/builtin/qml/" -1.-1 File as ""
    4. QDeclarativeImports(file::/builtin/qml/rrcbs/login.qml::importExtension: loaded ":/builtin/qml//qmldir"
    5. QDeclarativeImports(file::/builtin/qml/rrcbs/login.qml)::resolveType: "Rectangle" => "QDeclarativeRectangle"
    6. QDeclarativeImports(file::/builtin/qml/rrcbs/login.qml)::resolveType: "Text" => "QDeclarativeText"
    7. QDeclarativeImports(file::/builtin/qml/rrcbs/login.qml)::resolveType: "TextInput" => "QDeclarativeTextInput"
    8. QDeclarativeImports(file::/builtin/qml/rrcbs/login.qml)::resolveType: "FrameDark" => QUrl("qrc:/builtin/qml/FrameDark.qml")
    9. QDeclarativeImports(qrc:/builtin/qml/FrameDark.qml)::addImport: "." -1.-1 File as ""
    10. QDeclarativeImports(qrc:/builtin/qml/FrameDark.qml::importExtension: loaded ":/builtin/qml/qmldir"
    To copy to clipboard, switch view to plain text mode 
    Last edited by vallidor; 3rd August 2011 at 06:26.

  2. The following user says thank you to vallidor for this useful post:

    tipul07 (3rd August 2011)

  3. #2
    Join Date
    Apr 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Loading a qmldir from a qrc file

    If someone else have troubles with modules path, and find this thread from search:

    a) Replace qrc imprort to absolute path, to understand what directory you need.
    b) If you have module with a few subfolders, check folder names! It should be just the same as in qmldir, case sensitive.

Similar Threads

  1. Loading a TabLib .a File into project
    By Atais in forum Newbie
    Replies: 6
    Last Post: 9th February 2011, 22:22
  2. QML file not loading external JS file?
    By anothertest in forum Qt Programming
    Replies: 2
    Last Post: 14th April 2010, 09:11
  3. QPixmap not loading image(from file) after deployment.
    By csmithmaui in forum Installation and Deployment
    Replies: 4
    Last Post: 23rd February 2010, 02:44
  4. External Javascript file not loading initially
    By bkudrle in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2009, 17:05
  5. OpenGL file loading formats
    By TheKedge in forum Qt Programming
    Replies: 0
    Last Post: 6th August 2008, 15:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.