testGraphicsView角度旋转正确.rar

时间:2023-08-13 04:43:06
【文件属性】:
文件名称:testGraphicsView角度旋转正确.rar
文件大小:169KB
文件格式:RAR
更新时间:2023-08-13 04:43:06
qt qgraphicsitem qgraphicsscene qgraphicsview 通过qt图形视图绘制可拉伸矩形,圆等,并可随意旋转角度,继承qgraphicsitem if(isSelected()) { if(m_dir == Right && (event->buttons() & Qt::RightButton)){ double ang = 0; double x = m_cenPt.x()-m_movePoint.x(); double y = m_cenPt.y()-m_movePoint.y(); if(abs(x) > 0.001){ if(x < 0){ ang = atan(y/x)*180/PI; //通过弧度求角度 if(ang < 0) ang = atan(y/x)*180/PI 360; //通过弧度求角度 } else ang = atan(y/x)*180/PI 180; //通过弧度求角度 } double oldAng = rotation(); setTransformOriginPoint(m_cenPt); //设置旋转中心 setRotation(ang oldAng); //旋转角度,如果不加oldAng,则角度旋转不对 } else if(m_selectMod == SizeMode){ resizeTo(m_dir,event->scenePos()); } else QGraphicsItem::mouseMoveEvent(event); //如果在拉伸时也调用,则会位置设置不对 }
【文件预览】:
testGraphicsView
----testGraphicsView.pro.user(45KB)
----main.cpp(183B)
----graphicsview.h(369B)
----graphicscircleitem.h(2KB)
----graphicsscene.cpp(3KB)
----mydef.h(467B)
----mainwindow.h(714B)
----graphicsrectitem.h(2KB)
----graphicscircleitem.cpp(8KB)
----graphicsscene.h(748B)
----img.jpg(154KB)
----graphicsrectitem.cpp(8KB)
----mainwindow.cpp(2KB)
----graphicsellipseitem.h(2KB)
----mainwindow.ui(4KB)
----graphicsview.cpp(1KB)
----testGraphicsView.pro(2KB)
----graphicsellipseitem.cpp(8KB)

网友评论