PDA

View Full Version : Maya Style Right Click Menus in Qt



dvmorris
9th April 2007, 03:55
I would like to implement something like the maya-style right click menus (also called marking menus):

http://discussion.autodesk.com/servlet/JiveServlet/download/202-495994-5287303-120574/markingMenu.jpg

I was thinking the easiest way would be, say, if I have six choices I want to show, then just create six QMenu objects and display them radially around the mouse using popup(), but I tried a sample real fast, and the mouse focus only works on the most recently displayed QMenu object.

Ultimately I would want something as powerful as Qt PieMenu, but that seems to be only available for the commercial version of Qt. Does anyone have any ideas as to how to start implementing these radial right click menus with Qt opensource?

Thanks for the help,
dave

wysota
13th April 2007, 11:55
Shouldn't be that hard... Basically you're after a popup widget that may have a non-rectangular shape (obtained using setMask()) that triggers actions. The first big question is whether to subclass QMenu for that functionality or not. Looking at QMenu docs you'll notice there are no virtual methods to reimplement (obviously :P) so there won't be any benefit or subclassing QMenu for the job. So you should go for a QWidget (or QDialog) subclass and use addAction and handle QActionEvents to modify your custom menu.
Then it's a matter of reimplementing releaseMouseEvent to handle clicks and maybe mouseMoveEvent (with mouse tracking enabled) to provide some eye candy.