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. How to use variable from one qml to another qml

How to use variable from one qml to another qml

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 306 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.
  • Q Offline
    Q Offline
    qt_newbee
    wrote on last edited by
    #1

    Hello Everyone,

    I am new to Qt qml. I am unable to find a way to use a variable from one qml to another qml.
    My source qml has a variable like this,
    source.qml:
    //The flag will be set or reset based on the button events
    page {
    property int flag: 0

    onClicked {
    //some code here
    //setting the flag
    flag = 1;
    }
    }

    destination.qml
    Page {
    // some code here
    ...
    stackview.onActivated{
    if (flag == 1)
    {
    //send signal to c++ file
    process();
    }
    }
    }

    Can someone please help me understand how to use the flag in another qml file?

    Regards
    PK

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      if they share the same parent, define it inside the parent qml? If not, define it in a settings class(for example GlobalSettings).

      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