Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [SOLVED] Finding the corresponding action from Toolbar

    General and Desktop
    3
    4
    2213
    Loading More Posts
    • 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
      M_31 last edited by

      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 Reply Quote 0
      • L
        ludde last edited by

        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 Reply Quote 0
        • K
          koahnig last edited by

          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 Reply Quote 0
          • M
            M_31 last edited by

            Thanks ludde..its working fine with QSignalMapper

            1 Reply Last reply Reply Quote 0
            • First post
              Last post