Home > Back-end >  PaintEvent problems in QT
PaintEvent problems in QT

Time:11-26

Want to draw a radar map using QT, wrote the following procedures:
Void RadarDlg: : paintEvent (QPaintEvent *)
{
QPainter * painter=new QPainter (this);
Painter - & gt; SetRenderHint (QPainter: : Antialiasing);
Painter - & gt; SetRenderHint (QPainter: : SmoothPixmapTransform);
Painter - & gt; SetRenderHint (QPainter: : TextAntialiasing);
DrawRadarType (painter);
DrawLabel (painter);
DrawData (painter);
DrawAxisLabel (painter);
}
But when run, will report to:
QBackingStore: : endPaint () is called with an active painter on backingstore paint device
QPaintDevice: always destroy a paint device that is being made
Then add the begin to paintEvent () and end ()
Void CRadarDlg: : paintEvent (QPaintEvent *)
{
QPainter * painter=new QPainter (this);
Painter - & gt; The begin (this);
Painter - & gt; SetRenderHint (QPainter: : Antialiasing);
Painter - & gt; SetRenderHint (QPainter: : SmoothPixmapTransform);
Painter - & gt; SetRenderHint (QPainter: : TextAntialiasing);
DrawRadarType (painter);
DrawLabel (painter);
DrawData (painter);
DrawAxisLabel (painter);
Painter - & gt; The end ();
}
There is warning:
QPainter: : begin: Painter already active
Excuse me how to solve?

CodePudding user response:

Try the delete painter; Painter=NULL;

CodePudding user response:

reference 1/f, it is a nice nickname response:
try delete painter; Painter=NULL;

Try once, or not,

CodePudding user response:

refer to the second floor qq_41621832 response:
Quote: reference 1/f, it is a nice nickname response:

Try the delete painter; Painter=NULL;

Try once, or not,


 QPainter * p=new QPainter; 
P - & gt; The begin (this);
P - & gt; SetBrush (QBrush (QColor (222222123)));
P - & gt; ,0,10,20 drawRect (0);
P - & gt; The end ();
The delete p;
P=NULL;

CodePudding user response:

This doesn't work? The building Lord finally how to solve? Please comment,
  • Related