First, the basic graphic components
1, Qcustomplot provide text, arrows, lines, pictures and other graphic components to meet user needs. They are all inherited from the base class Qcpabstractitem.
The inheritance relationship is as follows:
Examples of crossing online:
//Add the text label at the top:Qcpitemtext*Textlabel= NewQcpitemtext (customplot); customplot -AddItem (Textlabel); Textlabel -Setpositionalignment (Qt:: AlignTop|Qt:: Alignhcenter); Textlabel -Position -SetType (qcpitemposition::p taxisrectratio); Textlabel -Position -Setcoords (0.5,0);//Place position at Center/top of axis rectTextlabel -SetText ("Text Item Demo"); Textlabel -SetFont (Qfont (Font ().Family (), -));//Make font a bit largerTextlabel -Setpen (Qpen (Qt:: Black));//Show black border around text//Add the arrow:Qcpitemline*Arrow= NewQcpitemline (customplot); customplot -AddItem (arrow); arrow -Start -Setparentanchor (Textlabel -bottom); arrow -End -Setcoords (4,1.6);//point to (4, 1.6) in X-y-plot coordinatesArrow -Sethead (qcplineending:: Esspikearrow);
Effect:
The code is simple and can be seen, but when we drag or zoom the image, the arrows are fixed at (4, 1.6) positions. You can refer to Qcpabstractitem and qcpitemposition for more information.
2, set the components in the entire Qcustomplot visible:
setClipToAxisRect(false);
Or you can set the rectangular area where you are located:
void QCPAbstractItem::setClipAxisRect* rect);
Typically, two functions are used together.
Qcustomplot User's Manual (iv)