Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Using an existing QAction object in a menu with Qt Creator
Forum Updated to NodeBB v4.3 + New Features

Using an existing QAction object in a menu with Qt Creator

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 2 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.
  • D Offline
    D Offline
    DerekDomino
    wrote on 14 Nov 2012, 18:13 last edited by
    #1

    Hello,

    I would like to use an existing QAction that I have instantiated and manipulating it (e.g.: settings some of its properties) in some part of my application and then insert it in a menu bar created through the wysiwyg tools of Qt Creator.

    Let's say the QAction is named myAction
    @
    //Create
    QAction *myAction = new QAction(tr(&Act and Play));

    //Configure
    myAction->setObjectName("ActAndPlay");
    myAction->setCheckable(true);
    ...
    @

    I've tried to add it to a menu created with the wysiwyg menu editor of Qt Creator,
    @
    ui->menuFromQtCreator->addAction(myAction);
    @
    but it the action is appended at the end of the menu, no way to specify its position in the menu.

    Do you know if there is a way to handle this? May be through the metaproperties?

    Thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on 14 Nov 2012, 18:49 last edited by
      #2

      If you know the QAction that you want to insert your action before, then you can use "insertAction(),":/doc/qt-4.8/qwidget.html#insertAction which QMenu inherits.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0

      1/2

      14 Nov 2012, 18:13

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved