PDA

View Full Version : QWidget::paintEngine() should no longer be called



Greeny
7th February 2007, 10:32
In Qt 4.1 I get the following error when trying to use QPainter in a function in a QLineEdit derived class:


QWidget::paintEngine() should no longer be called
QPainter::begin(), paintdevice returned engine == 0, type: 1


This is on Linux and I have tried to set:



setAttribute( Qt::WA_PaintOutsidePaintEvent, true );


as this painting is not happening in the paintEvent() function.

The line that triggers the message is:



QPainter painter(this);


Nothing is painted using the painter. Is this not possible to do or how could I paint in this function ?

wysota
7th February 2007, 10:38
Does "this" point to a widget?

aamer4yu
7th February 2007, 10:40
Where are u using the line
QPainter painter(this) ??

Greeny
7th February 2007, 10:48
The line is in the ::event(QEvent*) function of a class that is derived from a QLineEdit.

wysota
7th February 2007, 10:52
Hmm.... Why not do it the regular way - using paintEvent? Everything you draw in event will right away get discarded because the paintEvent will be called and it'll draw a regular line edit.

Greeny
7th February 2007, 10:59
Sure it could be rewritten, but the code works fine in Qt < Qt4 and I was kind of curious if it could be done in the same way to ease the porting.

wysota
7th February 2007, 11:01
The gap between Qt3 and Qt4 is very big, some concepts have changed, painting included.

Greeny
7th February 2007, 11:12
Well if there are no shortcuts I have to walk the long way, thanks anyway.