Results 1 to 2 of 2

Thread: why My Widget Initialize the display so slow?

  1. #1
    Join Date
    Apr 2016
    Posts
    37
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Post why My Widget Initialize the display so slow?

    hi , all.

    Now I have a question , My Widget Initialize the display so slow.

    code:
    MyWidget * pWidget = new MyWidget();//takes 200~300 ms
    ui->stackedWidget->addWidget(MyWidget);//takes 200~300ms

    MyWidget is my custom Widget. there are many "MyWidget" in my App.

    each MyWidget need invoke "new MyWidget();".

    MyWidget have many QWidget,QPushbutton,QLabel etc., about 50.

    each MyWidget use Qt Style Sheets and lots of images .

    i use qApp->setStyleSheet(style) in function main();

    sorry , my english sucks. I wrote down some ideas. Let me know what you cannot read.

    Win7 Qt 5.4.2

    inter core i5-4460 , ram 8GB

    Post your comments here.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: why My Widget Initialize the display so slow?

    Aside from the fact that one of the two lines of code you posted won't even compile, so it obviously isn't your real code... you haven't really told us anything that we can use to determine what could be wrong. There are "many" MyWidget instances in your app. OK, how many is "many"? 4, 40, 400, 4000? How many is "lots" of images? And how are you determining that each of these two lines of code takes 200 - 300 ms to execute?

    If each time you create a MyWidget instance you are creating "many" QWidget, QPushButton, and QLabel instances, and each time you load "lots" of images from disk files, then it isn't surprising that it takes a bit of time to do that.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 0
    Last Post: 22nd February 2010, 16:36
  2. toolTip of TreeWidgetItem display is slow
    By yunpeng880 in forum Qt Programming
    Replies: 0
    Last Post: 9th March 2009, 09:35
  3. QTable widget works slow :(
    By THRESHE in forum Qt Programming
    Replies: 3
    Last Post: 27th February 2008, 12:54
  4. QScrollBar + setToolTip speed on display ... to slow
    By patrik08 in forum Qt Programming
    Replies: 5
    Last Post: 26th February 2007, 13:27
  5. How to initialize properties to a custom plugin widget?
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2006, 16:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.