PDA

View Full Version : GUI application problems



Mek82
10th December 2010, 15:21
I'm creating a beautifull Multi-page GUI application with QT 4.6.3.
The GUI application has many pages and each one has a lot of custom widget.
At the beginning I have only created the 3 pages normally used but when I've started (launched) the application it takes 8-9 seconds to start.
I check the memory use it is about 60 MB (I have not finished the GUI application yet so in the future it will take more memory)
My questions are:
Is it normal that it takes 8-9 seconds to start/launch the application?
Does it become faster when I launch the application directly and not from Qt Creator?
What can I do to design and create a beautifull GUI application that take less time to start?

If someone has an idea or tell me where I made a mistake please tell me

Thank you

Mek82

Lykurg
10th December 2010, 16:34
I guess you are lunching it in debug mode. If you start it in release mode it should be faster. Or do you do heavy calculations on start up?

tbscope
10th December 2010, 16:35
Is it normal that it takes 8-9 seconds to start/launch the application?
It depends. Not knowing your program it is either true or false. Like a Schrödinger paradox.

For a normal, standard application, like a calculator, no this is not normal.


Does it become faster when I launch the application directly and not from Qt Creator?
It depends again. Do you run the application with a debugger attached inside Qt Creator?

Try building a release version too to see if the memory footprint can be lowered.

Otherwise, Qt Creator doesn't add a penalty to the speed of the program, at least not noticeable by a human being.


What can I do to design and create a beautifull GUI application that take less time to start?
Less is in reference to something. So, to answer your question, your first need to explain how you create your current application.

totem
10th December 2010, 16:59
also, it could be related to this thread (http://www.qtcentre.org/threads/31549-QT-4.6.3-regression-Dll-s-under-Windows-load-slow-compared-to-Qt-4.6.2) regarding the time it takes to load.
I don't know for the 60MB of memory usage though

edit : see the corresponding bug report (http://bugreports.qt.nokia.com/browse/QTBUG-11309)

wysota
10th December 2010, 17:31
Like a Schrödinger paradox.
It's not a paradox, it's quantum mechanics :)

Mek82
10th December 2010, 18:30
I try to do a multipage GUI application on a small pc board with Intel Atom N450 and 2GB of Ram.
That PC board comunicates by RS-232 with a Microcontroller board that deals analog and digital input/output.
The Qt GUI application when necessary comunicates with the microcontroller board by RS-232.
The GUI application is made of one QStackedWidget, in each pages I put one object.
The object X of class X inherit from UI::XForm, so I could create the graphic of the page inside the designer.
Sometimes the object is a single form with custom widget (.dll) like background, pushbutton, scrolltext, ecc... ; sometimes the object is made of another QStackedWidget.
At the beginning I only load the three mainly used pages.
I work in realese mode, and I have the same result also with Qt 4.6.0
Now I work in Windows Xp, but in the nearly future I have to make test with WinCe and Embedded Linux, so for me it is very important to understand why it takes so much times to load the program.

If someone has an idea or tell me where I made a mistake please tell me

Thank you

Mek82

tbscope
10th December 2010, 18:38
Do you load some large (graphics) files at start up?

squidge
10th December 2010, 19:01
I had a similar problem, I tracked down the problem using the debugger - I could see the program start up quickly and as I stepped through the creation of the classes, I noticed a 5 second delay on one of the classes. That class was searching for a configuration file and every time it attempted to open the file, Windows blocked execution for 5 seconds before returning with the error code.

For your case, I'd make use of the qDebug() statement, you may find that your program is starting quickly, but doing some time intensive work before showing the main window, which makes it look like its slow to startup.

Mek82
10th December 2010, 19:07
The custom widgets... background and pushButton was made using vectorial image... so yes I load large graphics, but not so large... vectorial image is a good compromize between quality and weight of graphics... I think that I could reduce something and improving something... but the program takes 8-9 seconds to load not 2 seconds... is too much.
I try to delete one custom object each time to understand if one of this have some bug or if one of this is the cause of the big load time.
Now the GUI application is at the beginning so I have to understand the correct way.
What do you thinking about using QML for GUI? and C++ for serial comunication and controls?
I don't know QML so I want to use if there is a big advantage

tbscope
10th December 2010, 19:22
I try to delete one custom object each time to understand if one of this have some bug or if one of this is the cause of the big load time.
If I understand you right, that's a good strategy. Start with a bare application, without any controls. Then, one by one try to add some things and see what consumes the memory and time.


and C++ for serial comunication and controls?
There's a Qt serial communcation class. Ideal if you use a microcontroller board that uses USB/serial communcation.


I don't know QML so I want to use if there is a big advantage
I don't think QML is the right answer here. You're doing something inefficient at some point in the application startup. It's hard to tell without code or a demonstration.

The problems I see from your information is that your program consumes a rather large amount of memory (60MB) That of course depends on how you measure it.
And it takes a long time to load. That to me sounds like a classic loading bottleneck.

wysota
10th December 2010, 19:33
There was an issue on Windows when Qt was trying to open some device (something related to multi-touch?) that caused the application to be stalled for about 10 seconds while initializing. I don't know if you're running on Windows now but if so then it might be happening to you too.

Mek82
13th December 2010, 18:35
I've probably understood one part of the problem. Two custom widgets are not perfectly built and they load other files. Now I have resolved that problem and the GUI application starts in 3 seconds. It is better, but is not perfect.
The GUI application creates three pages:
-) Page 1 has one background picture and 6 custom push button
-) Page 2 has one background picture and 2 custom push button
-) Page 3 has one background picture and 2 custom push button and other custom widgets

All the graphics is vectorial file (for example the backgroud graphics is around 100 kB - 200 kB).
I think that every single file is not heavy but I have to load about 30 files...
I don't know if 3 seconds is good or not good, I would like that the GUI application starts immidiatly.
What I can do?

If someone has an idea or tell me where I made a mistake please tell me

Thank you

Mek82

stampede
13th December 2010, 19:39
I think that every single file is not heavy but I have to load about 30 files...
Are you using Qt resource system ? http://doc.qt.nokia.com/4.0/resources.html
Or you just load every image from disk at startup ?

Mek82
13th December 2010, 20:31
Before I used Resource Systeme directly in the custom widget. The .dll file were quite heavy. Now I load the file at the beginning.

Mek82
15th December 2010, 14:57
I've done a lot of test. I used also Resource Systeme but the GUI application starts in 3 seconds. All the graphics to be loaded are about 1.4 MB. Is it normal that the GUI application starts in 3 seconds because it has to load 1.4MB of graphics?

If someone has an idea or tell me where I made a mistake please tell me

Thank you

Mek82

wysota
15th December 2010, 15:51
Does your GUI really load the graphics at startup? What types of graphics do you have? Is it compressed or not?

Mek82
15th December 2010, 16:22
Yes the GUI loads this graphics at the startup and lose time... 3 seconds....
Now I use the resource systeme inside each custom widget so the .dll is little more heavy but the graphics files are inside each .dll.
I use SVG graphics... all the graphics are 1.4 MB

Tell me what are you thinking

Thanks

wysota
15th December 2010, 16:33
SVG takes a bit of time to render. Considering it's text, 1.3MB must be quite a lot of things to draw. I don't know how much it should take but I doubt it will be snappy.

jdiewald
15th December 2010, 17:27
One of the things that you learn when you study performance analysis is that you can't be sure about where your program is slowing down until you actually measure it. There are a number of things that could be causing problems in this environment - and there are several good suggestions here. However, to be absolutely sure, you should find a performance analysis tool that runs on your system and measure what your program is actually doing. There may be several contributing factors that people could continue to guess about. Be sure. Measure.

Mek82
15th December 2010, 17:52
I've understood that the problem is the custom widget with SVG graphics... if I remove the custom widget the GUI application starts immidiatly.
If I put more graphics in the resource system the GUI application starts after more seconds.
In this way I've understood that the problem is in the loading of the SVG graphics.
Are 22 different graphics each one from 10 to 150kB and the total 22 graphics are 1.4 MB.
I don't know tool to check and monitor the performance if you could advise one I will be very happy...

Thanks

jdiewald
15th December 2010, 19:16
There are different tools depending on your platform. Most recently, I've used VTune (Intel) on Windows. In a previous job, I used (and helped develop) the DevPartner Studio performance tools (was NuMega, then Compuware, now Microfocus) on Windows. At my current job, they use Shark on the Macintosh. There are many other tools out there. A quick Google search of "performance analysis c++" turns up quite a few hits.

tbscope
16th December 2010, 05:34
Even if you don't have external tools, justs a fex QTime differences and debug lines give a rough estimate.

But, expect to have a larger loading time when you load and render svg files at startup. Unless you could load them later when the program is already running, you have to accept the load time. 3 seconds isn't that long anyway.