QMenu or QToolBar with a common action slot?

  • 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)
    if (toolbarButtonID==2)
    Any idea how I can achieve this?

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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.