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. Controlling a main.qml's Loader from a 'children' qml files
Qt 6.11 is out! See what's new in the release blog

Controlling a main.qml's Loader from a 'children' qml files

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 569 Views 2 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.
  • N Offline
    N Offline
    nazlab
    wrote on last edited by
    #1

    Hi,

    I am very new to Qt and QML. I have a main.qml file which has two views (kind of a splitview but manually made).

    In the first view, I load a qml filewhich contains a TabView . The contents of each tab would be loaded from other qml files. In each of these files I would like to have a button which would load the second view in the main.qml file.

    Is this approach possible? My main problem is how to make the qml files which are being viewed in the tabs to control the Loader in the main.qml.

    Thanks a lot!!!

    sierdzioS 1 Reply Last reply
    0
    • N nazlab

      Hi,

      I am very new to Qt and QML. I have a main.qml file which has two views (kind of a splitview but manually made).

      In the first view, I load a qml filewhich contains a TabView . The contents of each tab would be loaded from other qml files. In each of these files I would like to have a button which would load the second view in the main.qml file.

      Is this approach possible? My main problem is how to make the qml files which are being viewed in the tabs to control the Loader in the main.qml.

      Thanks a lot!!!

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @nazlab said in Controlling a main.qml's Loader from a 'children' qml files:

      Is this approach possible?

      Definitely!

      My main problem is how to make the qml files which are being viewed in the tabs to control the Loader in the main.qml.

      There are many ways to do it:

      • from your tabs, send a signal, which you can pick up in your main.qml and react by loading correct screen in your other view
      • define a Singleton, or a custom QObject added to root context property, which will contain certain signals - your tabs will fire those, and main.qml can react through a Connections {} component

      Hope it helps :-) I can get into more detail here, feel free to ask more detailed questions.

      (Z(:^

      N 1 Reply Last reply
      1
      • sierdzioS sierdzio

        @nazlab said in Controlling a main.qml's Loader from a 'children' qml files:

        Is this approach possible?

        Definitely!

        My main problem is how to make the qml files which are being viewed in the tabs to control the Loader in the main.qml.

        There are many ways to do it:

        • from your tabs, send a signal, which you can pick up in your main.qml and react by loading correct screen in your other view
        • define a Singleton, or a custom QObject added to root context property, which will contain certain signals - your tabs will fire those, and main.qml can react through a Connections {} component

        Hope it helps :-) I can get into more detail here, feel free to ask more detailed questions.

        N Offline
        N Offline
        nazlab
        wrote on last edited by
        #3

        @sierdzio Thank you for your reply - I really appreciate it. It will take some time to digest your instructions as I am very new to qt and qml - I have to read about signals and how they work. However, just yesterday I got it working by creating a property of Loader in the main qml file which refers to the view I want to load other views and then I am calling that property in the qml file that is loaded from the tabs qml file.

        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