hi, i want to create a button that when pressed it will display a context menu...
is there any widget that will do this, off the shelf?
is it easy to implement it by myself?
thanks for your time,
NA
hi, i want to create a button that when pressed it will display a context menu...
is there any widget that will do this, off the shelf?
is it easy to implement it by myself?
thanks for your time,
NA
You can use QContextMenuEvent.
Yes - QPushButtonis there any widget that will do this, off the shelf?![]()
Connect the clicked() signal to a slot, in that slot emit a QContextMenuEvent.
How about using QToolButton? It supports a menu with three different popup styles, out of the box.
J-P Nurmi
also any guide on how to do this?
I gave you the 'guide', what more do you need?
1. create a slot
2. connect the clicked() signal to that slot
3. in the slot emit the event
in the book c++ gui programming with qt4 i found another way{create an action, populate a menu, connect the menu with button}
Qt Code:
connect(oneAction, SIGNAL(triggered()), this, SLOT(action())); processMenu->addAction(oneAction); menuButton->setMenu(&processMenu);To copy to clipboard, switch view to plain text mode
what is the difference? between these 2 ways?
Last edited by aegis; 31st March 2007 at 19:29.
That's exactly the same what Jpn suggested.
The method from the book that Jpn suggested uses QActions and signals.what is the difference? between these 2 ways?
I find it also better, so use it.
The other method is using an event, which probably is what happens with the signal method behind the scenes.
Bookmarks