Time:03-23
if (! M_vehicleItem) {QString filename=QDir: : currentPath () + "/vehicle. PNG"; QDebug () & lt; <"Filename:" & lt; QPixmap image (filename); If (image. The isNull ()) {QDebug () & lt; <"Error: the image is not exist!" ; } QPixmap img=image. Three (4000, 2000, Qt: : KeepAspectRatio, Qt: : SmoothTransformation); M_vehicleItem=new QGraphicsPixmapItem (); M_vehicleItem - & gt; SetPixmap (img); //m_vehicleItem - & gt; SetShapeMode (QGraphicsPixmapItem: : HeuristicMaskShape); M_vehicleItem - & gt; SetOffset (m_vehicleItem - & gt; BoundingRect (). The width ()/2, m_vehicleItem - & gt; BoundingRect (), height ()/2); M_vehicleItem - & gt; SetFlag (QGraphicsItem: : ItemIsMovable); Scene () - & gt; AddItem (m_vehicleItem); } M_vehicleItem - & gt; SetPos (point); M_vehicleItem - & gt; SetRotation (60); Scene () - & gt; The update ();
m_TestRouteView=new TestRouteView (scene); Scene - & gt; SetView (m_TestRouteView); //scene - & gt; SetSceneRect (m_TestRouteView - & gt; Viewport () - & gt; The rect ()); M_TestRouteView - & gt; SetRenderHint (QPainter: : Antialiasing); M_TestRouteView - & gt; SetCacheMode (QGraphicsView: : CacheBackground); M_TestRouteView - & gt; SetOptimizationFlags (QGraphicsView: : DontSavePainterState); M_TestRouteView - & gt; SetViewportUpdateMode (QGraphicsView: : SmartViewportUpdate); //m_TestRouteView - & gt; SetViewportUpdateMode (QGraphicsView: : FullViewportUpdate); M_TestRouteView - & gt; SetTransformationAnchor (QGraphicsView: : AnchorUnderMouse);
Page link:https//www.codepudding.com/Backend/105443.html