我使用了QT示例:appchooser。我打算用它来实现工具栏。我修改它工作正常。
我有抓住点击事件的问题。我试过,但我没有得到解决方案。请帮我解决问题。
点击我需要调用ItemClicked()
方法
项目源代码。 http://www.4shared.com/file/Xutwi3DR/test4anime.html
请帮助找到解决方案..
答案 0 :(得分:2)
您必须对其进行子类化,因为virtual void grabMouseEvent ( QEvent * event )
(实际上所有鼠标事件)都受到保护,并且此窗口小部件的点击事件没有signals
。
class MyGraphicsWidget : public QGraphicsWidget{
Q_OBJECT
//Implement the constructors as you wish, if you need help with this check a Qt tutorial out.
//to get the mouse events implement the needed functions
//there are many others so just check the docs [1]
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ){
//do whatever you need here. Emit SIGNALS, show menus, etc
}
};
http://doc.qt.io/archives/qt-4.7/qgraphicswidget-members.html [1]