PDA

View Full Version : QPushButton:: Handle right mouse button events. Easyway?



Harvey West
28th February 2007, 11:38
Got a QPushButton widget which needs to trap the "right click", "right release" mouse events.

As far as I can see QPushButton::mousePressEvent(....) needs modifiying to do this.

Is there a simple way to do this without coding another QPushButton class.

Cheers

wysota
28th February 2007, 11:45
What do you want to do upon right click?

jpn
28th February 2007, 11:45
Got a QPushButton widget which needs to trap the "right click", "right release" mouse events.

As far as I can see QPushButton::mousePressEvent(....) needs modifiying to do this.

Is there a simple way to do this without coding another QPushButton class.
What is the task? What do you intend to do with the right mouse button press and release information?
This is just a wild guess, but are you maybe showing a menu of some kind? :) If so, maybe a QToolButton with it's built-in menu capabilities would be sufficient..?

Harvey West
28th February 2007, 11:59
Button needs to show text. Think Qtoolbar does not do this. Uses icons instead.
The event is used to launch a modeless Dialog ( with Table )
Action required is similar to the left mouse clicked button event. i.e. button animated down/up.

wysota
28th February 2007, 12:16
If you don't add an icon to QAction, it will show up as text in the toolbar.

BTW. If the dialog has a "context menu like" functions, you can react on customContextMenuRequested ( const QPoint & pos ) signal (just remember to switch the context menu property of the button so that this signal gets emitted).

aamer4yu
28th February 2007, 15:03
Also if u want to display text along with icon in the toolbar, you can use
void QToolBar::setToolButtonStyle ( Qt::ToolButtonStyle toolButtonStyle )
:)

Harvey West
28th February 2007, 16:56
QToolBar looking good for what i want. I'll give this a go. Cheers