截图工具中,需要画一个指向箭头,
该箭头的形状解析示意图如下所示,
对应的qt代码如下:
// 画出一个箭头线,主要是算出这几个点。
// 这个箭头形状是这样的,胖嘟嘟的那种,但是出发点是一个细的
QLineF lineOrigin(mPosStart,mPosEnd);
lineOrigin.setLength(lineOrigin.length()-arrowHeight);
QPoint offset(lineOrigin.dx(),lineOrigin.dy());
lineOrigin.setLength(arrowHeight);
lineOrigin.translate(offset);
//返回以相同起点的它的垂直线
QLineF line1 = lineOrigin.normalVector();
QLineF line2 = line1;
line1.setLength(arrowBottomInside/2);
line2.setLength(arrowBottom/2);
QLineF line3 = line2.normalVector().normalVector();
QLineF line4 = line3;
line4.setLength(arrowBottomInside/2);
newPath.moveTo(mPosStart);
newPath.lineTo(line1.p2().toPoint());
newPath.lineTo(line2.p2().toPoint());
newPath.lineTo(mPosEnd);
newPath.lineTo(line3.p2().toPoint());
newPath.lineTo(line4.p2().toPoint());
newPath.lineTo(mPosStart);
提示:QLineF QLineF::normalVector()函数作用,返回以相同起点的它的垂直线
标签:newPath,截图,lineTo,qt,lineOrigin,line1,QLineF,setLength,中画 From: https://blog.51cto.com/u_13682052/6991952