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. Composing multiple projects, referencing components
Forum Updated to NodeBB v4.3 + New Features

Composing multiple projects, referencing components

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 1.6k Views 1 Watching
  • 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.
  • PhrogzP Offline
    PhrogzP Offline
    Phrogz
    wrote on last edited by Phrogz
    #1

    Summary: How can I use a QML component from a sub-project in the main project?

    I have a project which stitches together components from two other projects, with each sub-project and the project that stitches them together in sub-directories. For example:

    .
    ├── app.pro
    ├── bar
    │   ├── bar.pro
    │   ├── bar.qrc
    │   ├── main.qml
    │   ├── main.cpp
    │   └── Bar.qml
    ├── combiner
    │   ├── combiner.pro
    │   ├── combiner.qrc
    │   ├── main.qml
    │   └── main.cpp
    └── foo
        ├── foo.pro
        ├── foo.qrc
        ├── main.qml
        ├── main.cpp
        └── Foo.qml
    

    The Foo and Bar apps have a .pro that loads their respective .cpp, which is mostly a wrapper for the main.qml that instantiates a Window to wrap the Foo.qml or Bar.qml class.

    My app.pro file references the sub-projects:

    TEMPLATE = subdirs
    CONFIG += ordered
    SUBDIRS = foo bar combiner
    app.depends = foo bar combiner
    

    In combiner/main.qml I want to be able to do:

    import QtQuick 2.8
    import QtQuick.Window 2.2
    import ??? // WHAT GOES HERE?
    Window {
        Foo { … }
        Bar { … }
    }
    

    I've tried import "foo".
    I've tried import "../foo".
    I've tried putting a qmldir file in the Foo directory with the contents module Foo and using import Foo 1.0.
    I clearly don't understand how all the references work, especially with sub-projects.

    How can I make foo/Foo.qml available to combiner/main.qml as a Foo component?

    1 Reply Last reply
    0
    • PhrogzP Offline
      PhrogzP Offline
      Phrogz
      wrote on last edited by
      #2

      Update: I tried adding:

      engine.addImportPath("foo");
      engine.addImportPath("../foo");
      

      to combiner/main.cpp before engine.load(), still no success.

      I've also tried adding Foo Foo.qml to foo/qmldir. Still no success.

      Ping?

      1 Reply Last reply
      0
      • ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        Hello,

        On this page : http://wiki.qt.io/Developer_Guides

        under : Introduction to Application Development with Qt Quick title, there are 3 Links to download
        the tuorial, and the 3rd part of that tutorial will answer you question.

        LA

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JeTSpice
          wrote on last edited by
          #4

          I've had a similar problem. The third part of the above linked tutorial is called "Qt Quick Core Principles for Application Development" I looked around that part and a few other parts but could not see a solution. Am I looking in the right place?

          ODБOïO 1 Reply Last reply
          0
          • J JeTSpice

            I've had a similar problem. The third part of the above linked tutorial is called "Qt Quick Core Principles for Application Development" I looked around that part and a few other parts but could not see a solution. Am I looking in the right place?

            ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by
            #5

            @JeTSpice Hello, this is not 3rd part, my bad. PART 8 : 8.1 Creating Components and Collecting Modules.
            I hope this is what you are looking for.
            LA

            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