Managing screens with QStackedWidget



  • Hello All,

    I have one screen with three QProgressBar and almost twenty QLabels.

    It is working fine, however it is too slow to show at the first time.

    I am using the QStackedWidget to manager my screens in my embedded application.

    When switch to other screens, the change is normal.

    What should I do to improve it?
    Reduce QLabels?, create QLabel dynamic?

    Thank all



  • It depends :-)

    Did you check where the time is gone?

    First show up includes creation of UI, loading libraries, ...
    The easiest would be use a profiler and check where the time goes, or use some logging/tracing to check it.
    After you checked where the time is used, you perhaps know what to do, not before....

    Don't try to optimize, if you don't know exactly where the bottleneck is. You will have much work and perhaps zero result.



  • Indeed, don't optimize blindly. Instrument your code, measure, and then find out where the bottlenecks are and tackle them one by one until you have a satisfying performance. Then, stop optimizing. Those last 20% of gains takes about 80% of your optimizing time, as a rule of thumb.

    What you might check, if if you are doing heavy lifting in your constructors. If you can avoid it, you might want to move such heavy initialization to a second phase, that you trigger with a 0 or very short interval timer. This makes sure that you get into a "running mode" quickly, that the user sees something happening immediately after starting.



  • [quote author="Andre" date="1300809795"]What you might check, if if you are doing heavy lifting in your constructors. If you can avoid it, you might want to move such heavy initialization to a second phase, that you trigger with a 0 or very short interval timer. This makes sure that you get into a "running mode" quickly, that the user sees something happening immediately after starting.[/quote]

    But also this only makes sense, if the bottleneck is really the creation of the widgets. Otherwise it makes the app more complex without any benefit. I never saw that creating widgets is costly, so the user sees it.

    What is costly, is if you have heavy user interface (in my example, I have here about > 1000 widgets in several tabs and stacks) that has a huge (>3000 lines) stylesheet. On my machine (3 GB ram, Win XP, Intel Core i% 2.4 GHz) startup takes some seconds (up to 20).

    The issue is mostly the complex stylesheet that is tracked during creation of the widgets... :-(

    But it's only a test for the style, our other apps only use some widgets and have no problem with the style sheet.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.