查看完整版本: [-- QGraphicsItem 选中 移动 --]

QTCN开发网 -> Qt移动平台开发 -> QGraphicsItem 选中 移动 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

huangrl2008 2015-06-30 09:59

QGraphicsItem 选中 移动

如题,对QGraphicsItem 鼠标按下去的情况下鼠标移动,能够实现图元移动。或者说能够响应mouseMove消息。
问题是,不按着鼠标时,鼠标移动却无法响应mouseMove消息。


请问,有没有那位大神知道怎么解决?

yuyu414 2015-06-30 10:44
setMouseTracking(true)

firebolt 2015-06-30 11:50
setAcceptHoverEvents(true);

huangrl2008 2015-07-01 08:01
yuyu414:setMouseTracking(true) (2015-06-30 10:44) 

这个接口是用在QWidget上,在图形/视图框架的QGraphicsItem里不能用

huangrl2008 2015-07-01 08:02
firebolt:setAcceptHoverEvents(true); (2015-06-30 11:50) 

怎么用?消息响应函数是?

firebolt 2015-07-01 09:01
huangrl2008:怎么用?消息响应函数是? (2015-07-01 08:02) 

GraphicsScene中必须有一个图元调用该方法后,scene才会向item传递鼠标消息。

huangrl2008 2015-07-06 08:06
firebolt:setAcceptHoverEvents(true); (2015-06-30 11:50) 

搞定了,在基础上添加响应函数即可

hll2423150 2016-07-06 21:19
huangrl2008:搞定了,在基础上添加响应函数即可 (2015-07-06 08:06) 

同学,我也遇到了这个问题,怎样在item中点击鼠标选中图形项然后再松开鼠标,移动鼠标,图形项跟着鼠标移动,setmousetracking貌似在item中不能用


查看完整版本: [-- QGraphicsItem 选中 移动 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled