PDA

View Full Version : How to enhance the display time of a QDialog like QWidget



reginaldt
5th July 2014, 02:59
When the form is a QDialog, it first display the main frame before its children widgets. I want it to be faster like when the form is QWidget it display the form and children at same time.

The form contains button that has images and QGraphicsDropShadowEffect and I know that it is the cause of slow UI. Even it is slow I want all of the widgets and form to display at the same time using QDialog. The code is old and I need to modify its dependent modules / procedures when I'm gonna change it to QWidget. Here are the codes regarding the form maybe one of these cause the issue.


this->setWindowFlags( Qt::Dialog | Qt::CustomizeWindowHint );
this->setAutoFillBackground(true);
this->setWindowModality(Qt::WindowModal);
this->setModal(true);

anda_skoa
5th July 2014, 11:37
I am not sure what you are saying.

The window shows up empty and then its contents starts appearing?

Cheers,
_

reginaldt
7th July 2014, 02:10
Yes. For example I have a dialog and its children are 3 push button. When I call the dialog it will pop up first before its children. But when it is widget it will show up once. Im using qt 4.7.3

anda_skoa
7th July 2014, 09:21
Since you have expensive graphics effects on some of the children, have you tried without them?

Cheers,
_

reginaldt
8th July 2014, 01:58
Yes recently I tried it already I remove the stylesheet on mainwindow and when I call a QDialog it still hapens but just a blink of an eye.

anda_skoa
8th July 2014, 07:37
Even without the drop shadow effect? Wow.

You could try positioning the window off-screen before showing and then moving it into view.

Cheers,
_

reginaldt
9th July 2014, 03:26
Is it normal that it is happening in our app? Our pro file includes 50folders and each folder have 3-10 classes. Even on the mainwindow form it happens too.

Is your suggestion ok even in this scenario?:
I show the widget, I hide it , and show it again and it still happened, the parent widget is shown first before its children. And some of it is exec() and not show().

d_stranz
10th July 2014, 01:48
Our pro file includes 50folders and each folder have 3-10 classes.

The size and organization of your project files has nothing to do with run-time performance. It might affect how long it takes to build the project, but once it is running it is just a big lump of code.

It sounds like your child widgets are doing a lot of unnecessary repainting. Put a qDebug() in your child widget paintEvent() and the parent widget showEvent() and see how many times the child is painted when the parent is shown.

reginaldt
11th July 2014, 03:33
The paint event is called every second because I update the display time.

d_stranz
11th July 2014, 17:55
I update the display time

I have no idea what that means, and it doesn't answer the question anyway. The question is not how many times you think the window is being repainted, it is how many times Qt is actually repainting it. Adding some code in the paintEvent() for the label that counts the number of times it is executed for each of your "update the display time" calls will tell you if there is excessive painting happening.

reginaldt
12th July 2014, 03:04
Sorry I didnt explain I mean the form have a QLabel that update its display every second that's the reason I think every second the qdebug I put on paintevent is keep showing. I cant determine if there is other cause of paint event aside from that. And on my qmainwindow I have a QMovie thats why I it keeps showing the Qdebug I put on paintevent too. But the showevent only called once on both.