PDA

View Full Version : Windows Binary Not Re-Painting Correctly



bpetty
6th September 2006, 18:04
I don't really know what the problem is... but when I compile my program and run it on another windows machine... it is very very chopy.

On the machines that I compile it on it runs very smoothly, but that is not the case on any other machine.

I think it is a painting issue. I did override this function:


void MainForm::paintEvent(QPaintEvent * /* event */)
{
QPainter paintGo(this); // Green Circle
QPainter paintStop(this); // Red Circle

showServiceStatus(paintGo, paintStop);
}


I have a timer that goes off every half second. when that happens it calls a function that does an "update()" to repaint everything. It appears that things are ONLY getting repainted when this timer triggers. Am I doing something wrong here?

wysota
6th September 2006, 18:31
Not likely. Maybe you're missing something on those other machines or maybe they're just much slower then the machine you compiled it on? Or maybe you used some compilation flags which don't work correctly on other configurations.

BTW. This seems little incorrect:

QPainter paintGo(this); // Green Circle
QPainter paintStop(this); // Red Circle
Why do you use two painters on the same widget here?

bpetty
6th September 2006, 23:01
Why do you use two painters on the same widget here?

I did that because showServiceStatus() will draw two circles... kind of like a stop sign. One QPainter object draws the "Go" light, the other draw the "Stop" light.

I created two objects because I feel it is cleaner from a software engineering point of view, but since I am very new to Qt... if you see something wrong with that please let me know.

As for my real problem... I still don't know what to do. I checked to make sure my other machine had all of the DLLs the exe was linked against. If I figure it out I'll let you all... incase anyone has a simular problem

wysota
6th September 2006, 23:22
I did that because showServiceStatus() will draw two circles... kind of like a stop sign. One QPainter object draws the "Go" light, the other draw the "Stop" light.

I created two objects because I feel it is cleaner from a software engineering point of view, but since I am very new to Qt... if you see something wrong with that please let me know.

Treat a QPainter object as a sheet of paper. You don't need two sheets of paper to draw two circles. You can draw one circle and then the other (on the same sheet). You made two sheets and you want to put then in the same place. I guess you won't see two circles this way...


As for my real problem... I still don't know what to do. I checked to make sure my other machine had all of the DLLs the exe was linked against. If I figure it out I'll let you all... incase anyone has a simular problem

Try using a single QPainter. Using two painters might be the cause of your problems.


void MainForm::paintEvent(QPaintEvent *){
QPainter painter(this);
painter.setBrush(Qt::red);
painter.drawEllipse(20, 20, 50, 50);
painter.setBrush(Qt::blue);
painter.drawEllipse(100, 100, 50, 50);
}