PDA

View Full Version : How to know when the server has completed the painting of the widget...??



kapoorsudhish
25th March 2010, 14:13
Hi,
I am doing a show on a particular widget, how can i come to know that the server has finished the painting of the widget and the widget is shown in the Ui. Does qt provide some flag or signal which tells me that the widget drawing is complete and the widget is shown...???


regards,
sudhish

axeljaeger
3rd April 2010, 15:33
You can play around with -sync
See http://qt.nokia.com/doc/4.6/qapplication.html#QApplication

Aster036
8th April 2010, 08:03
Hi,

You can override paintEvent method for the widget and declare a signal that emits a string which basically shows whether paint on the widget is finished or not?

your app.h

protected:
void paintEvent(QPaintEvent *e);

signal:

void catchevent(QString const);

your app.cpp

void widget::paintEvent(QPaintEvent *e)
{

emit catchEvent("paintEvent");

}

in main.cpp

you can use a TextEdit and append those events.

QTextEdit textedit;
connect(&widget,SIGNAL(catchEvent(QString)),&textedit,SLOT(append(QString)));

widget.show();
textedit.show();

you could actually appreciate the process you are interestered in.

axeljaeger
8th April 2010, 09:37
The problem with this approach is that for example on X11 the QPainter calls return although painting is not yet finished. This is because X11 does asynchronous painting by default.

kapoorsudhish
16th April 2010, 13:15
That's true as the paintEvent returns placing the request to the server, moreover i dont want to do this on each and every paint event, i just want to know as to when the widget painting was done or widget was completely shown on the screen.

I tried using the events like


QEvent::Show 17 Widget was shown on screen (QShowEvent).

but this also comes before widget is actually shown on the screen. Is there a signal or event by which i can know that the widget is finally shown on the screen??