Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Finding the corresponding action from Toolbar
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Finding the corresponding action from Toolbar

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.5k 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.
  • M Offline
    M Offline
    M_31
    wrote on 12 Sept 2011, 14:23 last edited by
    #1

    Hi All,
    I used "for loop" to create file toolbar Action.
    @
    void TestDlg::addActionstoFileToolbar()
    {
    QAction *action;
    for( int i=0;i<10;i++)
    {
    QString Name = QVariant(i).toString();
    action = new QACtion( Name, this);
    fileToolBar->addAction(action) // QToolBar *fileToolbar
    connect( action, SIGNAL(triggered(), this, actionHandler());
    }

    }

    void TestDlg::actionHandler()
    {
    /// hope this is the handler for all actions in File Toolbar ,
    ///but i want to know..which Action has pressed each time inside this SLOT
    }
    @

    After executing these code, i am able to see all the action from the toolbar.
    but i want to know..which Action has pressed each time inside this SLOT

    [edit, typo in title fixed, Eddy]

    1 Reply Last reply
    0
    • L Offline
      L Offline
      ludde
      wrote on 12 Sept 2011, 14:35 last edited by
      #2

      I would suggest you have a look at the "QSignalMapper":http://doc.qt.nokia.com/4.7-snapshot/qsignalmapper.html class.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on 12 Sept 2011, 14:36 last edited by
        #3

        One possibility would be to use "actionTriggered":http://doc.qt.nokia.com/4.7/qtoolbar.html#actionTriggered of the toolbar.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • M Offline
          M Offline
          M_31
          wrote on 12 Sept 2011, 15:44 last edited by
          #4

          Thanks ludde..its working fine with QSignalMapper

          1 Reply Last reply
          0

          1/4

          12 Sept 2011, 14:23

          • Login

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