1
我需要获取设置了QGraphicsItem::ItemIgnoresTransformations
标志的QGraphicsItem
的边界框(在场景空间中)。在Qt图形视图中获取恒定大小项目的边界框
根据文档,您需要使用QGraphicsItem::deviceTransform()来做到这一点。我尝试这样做:
// Get the viewport => scene transform
vp_trans = view.viewportTransform();
// Get the item => viewport transform
trans = item.deviceTransform(vp_trans);
// Get the item's bounding box in item's space
bbox = item.boundingRect();
// Map it to viewport space
bbox = trans.mapRect(bbox);
// Map it back to scene's space
bbox = vp_trans.mapRect(bbox);
可是,我错了,边框看起来更小和远来的物品的权利......
我遇到了和你一样的问题,并解决了这个问题。非常感谢! – 2016-03-16 20:12:50