引用楼主fox1987于2010-04-28 10:21发表的 问个关于重写mouse事件的问题 :
我想判断右键点击,
就继承了一个QWidget,
然后重写方法如下
void MyWidget::mousePressEvent(QMouseEvent* event )
{
.......
void QWidget::mousePressEvent ( QMouseEvent * event ) [virtual protected]
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events for the widget.
If you create new widgets in the mousePressEvent() the mouseReleaseEvent() may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.
The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.
See also mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent, and Scribble Example.