[Qt-interest] QLabel disable right-click menu

Jan janusius at gmx.net
Wed Jul 8 10:38:45 CEST 2009


Hi,

there is afaik a contextmenu option and there even is a special 
contextmenuevent.

qzvjtml02 at sneakemail.com schrieb:
> Hello.
> 
> 	I am trying to create my own QLabel right-click menu by writing my  
> own mouseReleaseEvent(). However, it appears that QLabel already HAS a  
> right-click menu that comes up with mousePressEvent(). I would like to  
> disable this menu! I wrote the following function:
> 
> void MyClass::mousePressEvent(QMouseEvent * event)
> {
> 	if (event->button() == Qt::RightButton)
> 	{
> 		event->accept();
> 	}
> 	else
> 	{
> 		QLabel::mousePressEvent(event);
> 	}
> }
> 
> I thought the event->accept() would say "Okay, capture this keypress  
> and don't let it go further" thus inhibiting the right-click menu. No- 
> go, the right-click menu still comes up. Am I doing this incorrectly,  
> or completely missing where the right-click menu is coming from?
> 
> 	Thanks for any help!
> 
> 		Kyle Fazzari
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 



More information about the Qt-interest-old mailing list