If this is your first visit, be sure to
check out the
FAQ
by clicking the
link above. You may have to
register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
Welcome to
Qt Centre
.
Qt Centre
is a community site devoted to programming in C++ using the
Qt framework
. Over 90 percent of questions asked here gets answered. If you are looking for information about Qt related issue —
register
and post your question.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our
free
community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please,
join our community today
!
If you have any problems with the registration process or your account login, please
contact us
.
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 run without problems, but the load (desterilize) shows the following error messages:
QPainter::setBrush: Painter not active
QPainter:: pen: Painter not active
QPainter::setPen: Painter not active
QPainter::drawRects: Painter not active
I have been trying for few days to eliminate these errors but without success.
Here a snippet of my paintevent-funktion:
Here is my whole project-code: bainedyal.de/painter.zip
If you have any idea please contact me.
Thank you!
QPainter works on a QPaintDevice, and in the case of QWidget you can't paint from outside a paint event. I really don't see why you need to paint anything in 'deserialize', however.
The way I understand it, you save the file by serializing the objects to a file stream (in 'serialize'). So, deserialize should do the opposite – that is, parse whatever data you read from the file according to the same rules and add objects correspondingly to the 'objects' vector. Then you simply call update() to repaint the widget (or rather, post an event that will be processed when the program returns to the main event loop).