[Qt-interest] creating context menu on button click
Ferenc Stelcz
ferenc at stelcz.hu
Thu Aug 20 20:31:43 CEST 2009
arjun wrote:
> Hi
>
> I am creating application in which i want to show different context menu on right mouse button click on different QPushbutton .
> How can i create context menu. please help for finding solution for given problem.
>
> Thanks
> Arjun
>
>
Please correct me if I'm wrong, but I may misunderstand your problem.
So you have a few QPushButtons and you want to show different right-click
menus for each. Right?
Is it inappropriate to use the setMenu(QMenu* menu) method of QPushButton to
associate a menu with your button? (Left click one)
If it is not a way you can follow then I suggest you create an own sublcass of
QPushButton and reimplement the MousePressEvent of it. To determine which
button and where was pressed use the button() and pos()/globalPos() functions
but be sure to read the docs before.
HTH
--
Ferenc Stelcz
Junior Software Engineer
Banyan Technologies LLC.
More information about the Qt-interest-old
mailing list