QT Drawing II: dynamic drawing a rectangle

This example also be implemented by rewriting the rectangle drawn paintEvent QWidget class virtual function.
1, the rendering requires a fixed rectangle
(1) can be held with the required dynamic resizing the window
rectangle width (2), a height of half the height of the window width of
example results as shown below:
QT Drawing II: dynamic drawing a rectangle

2, this embodiment changes the dynamic draw the rectangle on
(1) the four sides of a rectangular drawing is completed by one
(2) After completion of the rectangle drawn in the center of the background color fill
example results as shown below:
QT Drawing II: dynamic drawing a rectangle

Realization of ideas:
<1> in the upper left corner as a starting point (X0, Y0)
<2> described point reached right rectangular coordinate point (the X1, Y0)
<. 3> plot points down to the (the X1, Yl)
<. 4> Left describe arrived (X0, Yl)
<. 5> description upwardly arrived (X0, Y0)
<. 6> filling the background color

Examples of the above drawing can search for source station (QT Drawing II: rectangle Draw (Source)) or clicking the source code examples

Guess you like

Origin blog.51cto.com/7265851/2432207