QT draw a rotated line with arrows

Source: Internet
Author: User

Tesb::tesb (Qwidget *parent): Qwidget (parent) {UI.SETUPUI (this);}  void Tesb::D rawcustomline (qpainter& _painter, double _angle, double _len, const qstring& _name, const qcolor& _color) {//Initialize _painter.resettransform ();//Reset Brush _painter.translate (Qpoint (300,300)); _painter.setpen (QPen (Qt:: Black, 2));//Draw Segment Qline _line (Qpoint (0,0), Qpoint (_len,0)); _painter.rotate (_angle); _painter.drawline (_line);// Draw arrow int off_x = 10; Qpainterpath _path;_path.moveto (_len-off_x,-5); _path.lineto (_len,0); _path.lineto (_len-off_x,5); _ Painter.drawpath (_path);//Draw name _painter.setpen (_color); Qfont _font = _painter.font (); _font.setpointsize; _font.setbold (true); _painter.setfont (_font); _ Painter.drawtext (Qpoint (_len-2*off_x,-10), _name);} void Tesb::p aintevent (qpaintevent *ev) {qpainter _painter (this); _painter.setpen (Qpen (Qt::black, 2));//Anti-aliasing _ Painter.setrenderhint (qpainter::antialiasing);//Move the Brush center point to (300,300) _painter.translate (Qpoint (300,300));//Draw Center Point _ Painter.drawpoint (Qpoint (0,0));//Draw an outer circle _painter.drawelliPSE (Qrect ( -150,-150,300,300));D rawcustomline (_painter, 0, Max, "Da", qt::red);D rawcustomline (_painter, 123.5, 130, " Db ", Qt::green);D rawcustomline (_painter, -45," Dc ", Qt::blue);D rawcustomline (_painter, -145," Dd ", Qt::yellow); Qwidget::p aintevent (EV);}


QT draw a rotated line with arrows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.