Home > Mobile >  For each use painEvent compilation has not passed
For each use painEvent compilation has not passed

Time:10-09

Error said no definition, can not find a file, don't know what to do, teach me how to change, thank you,

CodePudding user response:

PaintEvent is the virtual functions QWidget,
If you want to write to your widget class paintEvent method,
Code should be such,
 
Void Widget: : paintEvent (QPaintEvent *)
{
QPainter p=(this);
Conviction yourself rawPixmap (0, 0, QPixmap (" :/resource/img. PNG "));
}

Rather than
 
Void QWidget: : paintEvent (QPaintEvent *)
{
QPainter p=(this);
Conviction yourself rawPixmap (0, 0, QPixmap (" :/resource/img. PNG "));
}

CodePudding user response:

reference 1st floor qq_41070051 response:
paintEvent is the virtual functions QWidget,
If you want to write to your widget class paintEvent method,
Code should be such,
 
Void Widget: : paintEvent (QPaintEvent *)
{
QPainter p=(this);
Conviction yourself rawPixmap (0, 0, QPixmap (" :/resource/img. PNG "));
}

Rather than
 
Void QWidget: : paintEvent (QPaintEvent *)
{
QPainter p=(this);
Conviction yourself rawPixmap (0, 0, QPixmap (" :/resource/img. PNG "));
}

Solved oh oh oh good thank you, excuse me why even if changed to a Widget when quoting painEvent or there is a small lock?

CodePudding user response:

reference pictures on the second floor - wave response:
Quote: refer to 1st floor qq_41070051 response:
paintEvent is the virtual functions QWidget,
If you want to write to your widget class paintEvent method,
Code should be such,
 
Void Widget: : paintEvent (QPaintEvent *)
{
QPainter p=(this);
Conviction yourself rawPixmap (0, 0, QPixmap (" :/resource/img. PNG "));
}

Rather than
 
Void QWidget: : paintEvent (QPaintEvent *)
{
QPainter p=(this);
Conviction yourself rawPixmap (0, 0, QPixmap (" :/resource/img. PNG "));
}

Solved oh oh oh good thank you, excuse me why even if changed to a Widget when quoting painEvent or there is a small lock?


You declare paintEvent method is protected, the Qt Creator for non-public method will bring a small lock icon,

CodePudding user response:

reference qq_41070051 reply: 3/f
Quote: refer to the second floor picture - wave response:

Quote: refer to 1st floor qq_41070051 response:
paintEvent is the virtual functions QWidget,
If you want to write to your widget class paintEvent method,
Code should be such,
 
Void Widget: : paintEvent (QPaintEvent *)
{
QPainter p=(this);
Conviction yourself rawPixmap (0, 0, QPixmap (" :/resource/img. PNG "));
}

Rather than
 
Void QWidget: : paintEvent (QPaintEvent *)
{
QPainter p=(this);
Conviction yourself rawPixmap (0, 0, QPixmap (" :/resource/img. PNG "));
}

Solved oh oh oh good thank you, excuse me why even if changed to a Widget when quoting painEvent or there is a small lock?


You declare paintEvent method is protected, the Qt Creator for non-public method will bring a small lock icon,

Oh oh oh see see thank you
  •  Tags:  
  • Qt
  • Related