Home > Mobile >  QT implementation after clicking the button with the mouse on the qlabel draw a rectangle?
QT implementation after clicking the button with the mouse on the qlabel draw a rectangle?

Time:10-10

QT small white for help, after how to click a button on the qlabel draw a rectangle with the mouse, and get the parameters of the rectangular???
I have found that to use qlabel a subclass to implement, and then click on the groove function how to specific implementation?? What is the signal inside the??

CodePudding user response:

Simple drawing first to understand, click the button, start drawing on qlabel, mouse click start painting, release the mouse over drawing, this should be good implementation, online about drawing a lot of examples, can refer to baidu,

CodePudding user response:

Want to drawing in QLabel, does need go to inherit QLabel, then paintEvent () function to realize the corresponding drawing, the mouse to click and move should use QT event system, concrete is to use the following two events:
Void mousePressEvent (QMouseEvent * event);
Void mouseMoveEvent (QMouseEvent * event);
The two events is a virtual function, in your inheritance of class to achieve what you want in the operation,

CodePudding user response:

Qt drawing must be limited in a PaintEvent function is very big, I don't know is there a way to bypass?

CodePudding user response:

reference ooolinux reply: 3/f
Qt drawing must be limited in a PaintEvent function is very big, I don't know is there a way to bypass?


Can not draw on the QPixmap?

CodePudding user response:

this is a nice nickname reference 4 floor response:
Quote: refer to the third floor ooolinux response:

Qt drawing must be limited in a PaintEvent function is very big, I don't know is there a way to bypass?


Can not draw on the QPixmap?


This method is slow, the timer has been drawing see come out,
  •  Tags:  
  • Qt
  • Related