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 Are QML Actions supposed to be used?
Qt 6.11 is out! See what's new in the release blog

How Are QML Actions supposed to be used?

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

    In the qml gallery examples one finds this code:

        Action {
            id: copyAction
            ...
        }
    ...
        Menu {
                title: "&Edit"
                visible: tabView.currentIndex == 2
                MenuItem { action: cutAction }
                MenuItem { action: copyAction }
                MenuItem { action: pasteAction }
            }
    

    That is very nice, when action and menu are in the same file. But what if they are not? What if I want to use the same action at multiple places in different files? What is the idea here?

    Thanks!
    Nathan

    1 Reply Last reply
    1
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

      The procedure should be the same as for any other Qml object. Some common strategies include:

      • create the Action-containing object as a child of the component that uses it
      • export as a global property from C++
      • define as a singleton
      • implement a custom registration and lookup facility

      Asking a question about code? http://eel.is/iso-c++/testcase/

      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