-1

I'm trying:

  connect(myButton, SIGNAL(mouseReleaseEvent(QMouseEvent*)),
    this, SLOT(ShowContextMenu(QMouseEvent*)));

but getting error message:

QObject::connect: No such signal QToolButton::mouseReleaseEvent(QMouseEvent*)

qt 5.4 - what am I doing wrong there?

cnd
  • 32,616
  • 62
  • 183
  • 313
  • 2
    ***what am I doing wrong there?*** mouseReleaseEvent is not a signal so you can not connect it to a slot. – drescherjm Dec 29 '15 at 07:45
  • @drescherjm so to catch right click I need something alike my own button? – cnd Dec 29 '15 at 07:56
  • If you make your button inherit from QToolButton you should be able to handle the mouseReleaseEvent and emit your own signal. I am not sure if there is a simpler method. – drescherjm Dec 29 '15 at 08:07

1 Answers1

1

Assuming that myButton is of the class QPushButton, you can use the released() signal:

connect(myButton, SIGNAL(released()),
    this, SLOT(ShowContextMenu()));

Assuming that the slot 'ShowContextMenu' can be called without an argument. See also the QT Documentation.

DrDonut
  • 864
  • 14
  • 26
  • 3
    Sorry, I did not know that... So you mean like [here](http://stackoverflow.com/questions/15658464/qt-rightclick-qpushbutton)? – DrDonut Dec 29 '15 at 08:02