Qt drawing column

  • Drawing event: if drawing on the window, it must be placed in the drawing event

Insert picture description here

  • The function used to draw the background image: Qpainter object.drawPixmap

  • The function used to draw the rectangle: Qpainter object.drawRect, of course, the painter must be handed over to the painter before this: Qpainter object.setpen(pen)

  • If you want to implement a function, you need to refresh the window and let the window be redrawn, just execute the update() statement in the slot function. It is equivalent to calling paintEvent() indirectly.

  • QPixmap is the parent class of QBitmap. The latter has only two colors, and the former is a color image. The above and below are different methods, and both can be used.

- ###

  • Commonly used drawing equipment (drawing board): QPixmap (optimized for the screen, and platform-related, can not modify the picture, generally used for display), QImage (related to the platform, you can modify the picture, you can draw in the thread) , QPicture (save the state of the drawing-binary file), the usage of the three of them is basically similar,If you use them as a drawing device, you can put it in the constructor, and you don’t need to put it in the drawing event.

  • Conversion between QPixmap and QImage: pixmap.toImage() or Pixmap::fromImage(image) function can realize the conversion between the two.

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42308217/article/details/113483644