hashb
30th August 2010, 03:27
platform :QT4.6,QT4.7 linux
Hi, All,
I got a very strange problem about paintEvent.
Here is my code
....
status = true; //set status to true by default
....
void MainWindow::paintEvent(QPaintEvent * event )
{
qDebug()<<"paintEvent";
QMainWindow::paintEvent(event);
QPainter p(this);
if(status)
p.drawText(110,110,"hello");
else
p.drawText(110,110,"world");
}
void MainWindow::on_pushButton_clicked()
{
if(!status)
status = true;
else
status = false;
}
Here is my steps:
1. start app , on the window it shows "hello"
2. click button, status changed to false
3. move the window to the edge of the screen ,until it become invisible.
4. move the window back to the center of the screen
5. from debug info,I can see that paintEvent has been called,
but what puzzled me is that in the window, it still shows "hello" !!! :confused:
6. minimize the window and the raise it again, the window also still shows "hello" :confused:
7. resize the window ,now it shows "world"
any ideas about it ?
Thanks in advance for your help.
Best regards,
hb
Hi, All,
I got a very strange problem about paintEvent.
Here is my code
....
status = true; //set status to true by default
....
void MainWindow::paintEvent(QPaintEvent * event )
{
qDebug()<<"paintEvent";
QMainWindow::paintEvent(event);
QPainter p(this);
if(status)
p.drawText(110,110,"hello");
else
p.drawText(110,110,"world");
}
void MainWindow::on_pushButton_clicked()
{
if(!status)
status = true;
else
status = false;
}
Here is my steps:
1. start app , on the window it shows "hello"
2. click button, status changed to false
3. move the window to the edge of the screen ,until it become invisible.
4. move the window back to the center of the screen
5. from debug info,I can see that paintEvent has been called,
but what puzzled me is that in the window, it still shows "hello" !!! :confused:
6. minimize the window and the raise it again, the window also still shows "hello" :confused:
7. resize the window ,now it shows "world"
any ideas about it ?
Thanks in advance for your help.
Best regards,
hb