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. QMenu or QToolBar with a common action slot?
Forum Updated to NodeBB v4.3 + New Features

QMenu or QToolBar with a common action slot?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.0k 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
    floatingWoods
    wrote on last edited by
    #1

    Hello,

    I managed having my QToolBar and QMenu work nicely in the Qt framework using the signal/slot mechanism (with QAction). However, since I am porting a rather large application from MFC where I used a common message handling routine for toolbar presses, menu selections, etc., I want to reuse it.
    Practically this means that for any toolbutton press (or menu selection), the same slot should be called, and then inside that slot routine, I need to identify which button was pressed. A little bit something like:

    @
    void aToolbarButtonWasPressed(int toolbarButtonID)
    { // This would be called when any toolbar button is pressed
    if (toolbarButtonID==1)
    clearScene();
    if (toolbarButtonID==2)
    openScene();
    ...
    }
    @
    Any idea how I can achieve this?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cincirin
      wrote on last edited by
      #2

      Look at "QSignalMapper":http://doc.qt.nokia.com/stable/qsignalmapper.html class

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

        Excellent! Exactly what I was looking for, thanks a lot.

        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