Results 1 to 10 of 10

Thread: dynamically loaded components cannot reference types

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2014
    Location
    Gelnhausen, Germany
    Posts
    21
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: dynamically loaded components cannot reference types

    Resolving paths relative to the calling document prevents these problems.
    well, I still am not convinced. In my non-plugin scenario, I had the components in a subdirectory. If I directly referenced the root component via directory import, it was found and all nested types as well. If I load the root component through a Loader, suddenly nested components are NOT found. Again:

    Qt Code:
    1. main.qml
    2. navigation
    3. Reusable.qml <-- uses Nested
    4. Nested.qml
    To copy to clipboard, switch view to plain text mode 

    now, if in main.qml I simply do a directory import and use the Reusable type, everything works well:
    Qt Code:
    1. import "navigation"
    2. Rectangle {
    3. Reusable {
    4. }
    5. }
    To copy to clipboard, switch view to plain text mode 
    However, if I load Reusable dynamically
    Qt Code:
    1. Rectanngle {
    2. Loader {
    3. source: "navigation/Reusable.qml"
    4. }
    5. }
    To copy to clipboard, switch view to plain text mode 
    I see an error message that file "navigation/Nested.qml" was not found. In a plugin scenario, the message simply says "Nested is not a type". If this makes sense somehow, it is still almost impossible IMO to find a smooth path from that message to a solution, which may mean that the concepts are not that clear and plausible, or at least not well explained. As I said, it took a day of desperate poking for me.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: dynamically loaded components cannot reference types

    With the first approach you are effectively importing all types defined in "navigation" into the scope of the current document (in other words "navigation" becomes a sort of plugin that contains documents present in that directory). In the second approach you get regular path resolution. Whether this works or not, depends on the scope of the containing document (i.e. the location of the file containing the last snippet).

    If you want to load "Reusable" from within main.qml, you will refer to "navigation/Reusable.qml" or "Reusable.qml" having imported "navigation" module. If you want to load "Reusable" from Nested.qml, you will have to refer to Reusable.qml directly.
    Last edited by wysota; 16th August 2014 at 16:21.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QML list and dynamically loaded content
    By matsukan in forum Qt Quick
    Replies: 5
    Last Post: 21st November 2013, 09:41
  2. Layering components with QT
    By David Krutsko in forum Newbie
    Replies: 0
    Last Post: 27th October 2010, 00:33
  3. Replies: 4
    Last Post: 10th December 2009, 17:37
  4. ui components
    By addu in forum Qt Programming
    Replies: 0
    Last Post: 17th September 2009, 15:49
  5. Q_ARG with C++ reference types
    By RichardNixon in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2008, 10:11

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.