1. Drawing graphics
[CPP]View Plain copy protected:void paintevent (qpaintevent *); void Widget::p aintevent ((qpaintevent *event) {qpainter painter (this);//this as a drawing device, that is, drawing on the part Painter.draw Line (qpaint (0, 0), Qpaint (100, 100)); } qpainter painter (this); Will immediately begin drawing on the device, call the Begin () function automatically, and then call the end () function in the destructor to finish drawing.
Qpainter painter;//without parameters, you can call Qpainter::begin (Qpaintdevice *device) later to specify the drawing settings, and then call the end () function when you are finished.
Equivalent to
[CPP]View plain copy void Widget::p aintevent ((qpaintevent *event) {qpainter painter; Painter.begin (this); Painter.drawline (qpaint (0, 0), Qpaint (100, 100)); Painter.end (); } 2. Using Paint brushes
Paint brush to set color and fill modes
[CPP]View Plain copy Qbrush brush (Qcolor (0,0,255), Qt::D ense4pattern); Painter.setbrush (brush); 3. Using brushes
[CPP]View plain copy//parameters are: Paint brush, line width, brush style, draw nib Point, brush connection style Qpen pen (qt::green, 5, Qt::D otline, Qt::roundcap, Qt::roundjoin); Painter.setpen (pen); 4. Draw a Rectangle
[CPP]View Plain copy painter.drawrect (0, 0, 100, 80); X,y,w,h 5. Draw Ellipse (circle)
[CPP]View Plain copy painter.drawellipse (0, 0, 100, 80); X,y,w,h 6. Drawing arcs
[CPP]View Plain copy QRECTF rect (70.0, 40.0, 80.0, 60.0); X,y,w,h
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.