PDA

View Full Version : QTextEdit not being updated



doggrant
2nd September 2009, 16:20
Hi,

I've got a dialog which contains a QTextEdit.

In the dialog's constructor, I call this->show(), then use a QProcess() to run an external process. I connect to the readyReadStandardOutput signal to update the QTextEdit with the QProcesses output. However the text is not being updated in the QTextEdit.

If I activate and deactivate the dialog, by clicking on other windows on my system, everything updates, but if not, the dialog is not updated. The same code worked fine in QT3.

regards,

David

victor.fernandez
2nd September 2009, 16:33
Could you post the code?

doggrant
2nd September 2009, 17:06
I've just found the problem, but i'm not sure what has caused it.

In the new QT4 code (This is a port of an app from QT3 to QT4, that i've stared work on half way through).

The dialog had the following functions defined in the header :-



virtual void showEvent( QShowEvent* ShwEvt );
virtual bool event( QEvent* Evt );


and in the cpp file



void myclass::showEvent( QShowEvent* ShwEvt )
{
QDialog::showEvent( ShwEvt );
QApplication::processEvents();
}


bool myclass::event( QEvent* Evt )
{
if ( Evt->type() == QEvent::Show )
{
/**
processing code, which I actually removed from here
so all it was doing was returning true.
**/
return true;
}


return false;
}


why would this code stop my screen updating? since removing it causes everything to be ok.

victor.fernandez
2nd September 2009, 17:25
I think it's because event() is the main event handler, which is supposed to take care of all kinds of events. If you reimplement it and you don't call the parent class' event() method, your widget won't receive paint events among others, so paintEvent() is not invoked. I would recomment you to remove event() and just use showEvent().