You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Saturday, July 30th 2011, 9:06am

Painter not active

Hello all!
I am new in QT C++ Programming and I hope to get some help here.

I am trying to make a simple program with QT.
My goal is to save the parameter of objects to a file and then to load these backwards from the file.

The painting and save-function runs without problems, but the load (desterilize) shows the following error messages:

Source code

QPainter::drawRects: Painter not active

I have been trying for few days to eliminate these errors but without success.

If you have any idea please contact me.

Thank you!

This post has been edited 6 times, last edit by "zerdayiso" (Aug 19th 2011, 6:55am)


Tuesday, August 2nd 2011, 4:49pm

You can't do anything with painter but in the paintEvent.
Move the code that refers to painter from deserialize to the paintEvent itself. There, you can use the previous read data (x, y, z, z1).

In the serialize function, after load data just call update to invoke the paintEvent.
Take care of default values of x, y, z, z1 or use a flag to know if you're painting loaded data.


Thursday, August 4th 2011, 10:05am


I have done it!