PDA

View Full Version : qt3 to qt4 conversion: debug messages



hugo vanwoerkom
14th October 2007, 19:57
Hi,

I am converting a rather large project that runs on qt3 on Linux to run on qt4 on XP (because there is no qt3 opensource for XP).

(XP runs as a vmware client on the Debian Sid Linux host).

I get lots of:
QWidget::repaint: Recursive repaint detected
and
QPainter::begin: Widget painting can only begin as a result of a paintEvent

And no icons show up in the main window and no editor windows open up.

So in an attempt to find what in the code is doing that I did a qt debug library build from its shortcut in Qt by Trolltech v4.3.1 (OpenSource).

Then I added CONFIG += debug and CONFIG += console to the pro file and reran qmake and redid the make.

But to my surprise I got no added messages at all.

Is there a way to find out what in the code makes those messages appear? There are over a 100 modules and 1000's of lines of code :-(

Hugo

marcel
14th October 2007, 20:05
QWidget::repaint: Recursive repaint detected
Happens when calling repaint() from a paint event. This shouldn't be done.
Solution: review the code and fix it.



QPainter::begin: Widget painting can only begin as a result of a paintEvent
Happens when painting on widgets outside paint events. In Qt 3 this was possible but not in Qt 4. In 4 you can only draw on a widget in its paintEvent.
The solution for this one is to examine all the code and rewrite those parts.
So, wherever you see
QPainter p(someWidget) outside the widgets paint event, then you must rewrite that code.

Brandybuck
15th October 2007, 18:38
Many Qt3 programs would paint outside of paint events. This was common for graphs, when you would want to plot a point as soon as some new data came in. One good way to port this style of painting, is to paint to a pixmap instead of the widget. You can paint to a pixmap at any time, then call update() to schedule a paint event. Then in the paintEvent() just draw the pixmap.

hugo vanwoerkom
15th October 2007, 19:08
Thanks!

This proves a formidable challenge. gdb showed that the recursive repaints came from processEvents calls that were all over the place. Eliminating those got rid of the message but leaves the app screen looking ridiculous: an empty frame while a very complicated plot is drawn consisting of thousands of lines.

Hugo