Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, April 2007
QGraphicsItem


Message 1 in thread

Hi,
 
QGraphicsItem is not a QWidget. Due to this, I cannot set my context
menu for that
particular graphic item by setContextMenuPolicy. I have to look at the
mouse current position, check if
any graphics item is below it and then show the current contextmenu from
QGraphicsView, which is a QWidget.
Wouldnt it be better, if each GraphicsItem could itself handle its own
context menu ? 
Maybe there is a way to do it, if yes, would someone tell me how ?
 
Thnx
Prateek

Message 2 in thread

Prateek Tiwari schrieb:
> Hi,
>  
> QGraphicsItem is not a QWidget. Due to this, I cannot set my context 
> menu for that
> particular graphic item by setContextMenuPolicy. I have to look at the 
> mouse current position, check if
> any graphics item is below it and then show the current contextmenu 
> from QGraphicsView, which is a QWidget.
> Wouldnt it be better, if each GraphicsItem could itself handle its own 
> context menu ?
> Maybe there is a way to do it, if yes, would someone tell me how ?
>  
> Thnx
> Prateek
Hi Prateek,

is it an option to subclass QGraphicsItem as it is done in the 
API-documentation?
http://doc.trolltech.com/4.2/qgraphicsitem.html#contextMenuEvent

That's the easiest way I think...
As you can see, the QGraphicsItem is no QObject, so it has no mechanism 
to send signals, so there is no method like
http://doc.trolltech.com/4.2/qwidget.html#customContextMenuRequested

That's at least how I understand it.

Hope that helps, regards

Daniel

-- 
 [ signature omitted ]