PDA

View Full Version : QPainter error: no match for call ...



tonnot
7th October 2010, 11:43
If I have a private QPainter :

QPainter the_painter;

If I use at paintEvent :
void AnalogClock:: paintEvent(QPaintEvent *)

{
the_painter(this);
....
I have :
error: no match for call to '(QPainter) (AnalogClock* const)'

I dont understand what is happen.
Any idea?

wysota
7th October 2010, 11:50
The compiler is certainly right. This call:

the_painter(this);
is a function call of a function called "the_painter" passing it a "this" argument.

I know you meant to call a constructor but the object is already constructed, you can't call a constructor directly in this context. Use QPainter::begin() (and then QPainter::end()) or don't store the painter as a member variable but instead create a local variable in the event handler.

tonnot
7th October 2010, 12:00
Aha ! Ok !