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. QtQuick Action in C++ (or at least a separate .qml file)
Forum Updated to NodeBB v4.3 + New Features

QtQuick Action in C++ (or at least a separate .qml file)

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.8k 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.
  • F Offline
    F Offline
    ftkalcevic
    wrote on last edited by
    #1

    When I deploy my app, I want the users to be able to customise the GUI, but not change/break the functionality. Is it possible to create QtQuick Action objects in C++?

    I've tried using QAction, but that didn't work.

    I've seen QQmlAction come up when googling, but it looks like it is from the QtControls internals.

    Can this be done.

    My 2nd idea is to hide the Action objects from the user so they don't accidentally change them. Is it possible to move Action objects into a separate .qml file and connect them up to menus, toolbars, etc

    Thanks,
    Frank

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      2nd option is definitely possible. Define actions in different file with Ids. Use this ids to associate.

      First option is doubtful.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • F Offline
        F Offline
        ftkalcevic
        wrote on last edited by
        #3

        How do I define more than one action in a single file? There can only be one root object? What can i use for a container?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          ftkalcevic
          wrote on last edited by
          #4

          I've tried a few things. The simplest was to define the Action object in it's own file...

          ActionOpenGCode.qml
          @
          import QtQuick 2.2
          import QtQuick.Controls 1.1
          import QtQuick.Layouts 1.1
          import QtQuick.Dialogs 1.1
          import nexis 1.0

          Action {
          text: "&Open"
          shortcut: StandardKey.Open
          iconSource: "../images/tool_open.gif"
          tooltip: "Open a G-Code File"
          }
          @

          And then in main.qml
          @
          ActionOpenGCode {
          id: actionOpenGCode
          }

          menuBar: MenuBar {
              Menu {
                  title: "&File"
                  MenuItem { action: actionOpenGcode }
          

          @

          I get the error...

          file:///home/frankt/svn/nexis/nexis/qml/main.qml:226: ReferenceError: actionOpenGcode is not defined (which is line 8 of the main.qml snippet)

          Am I doing this right?

          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