Results 1 to 2 of 2

Thread: Less cost by setting QWidget's background color?

  1. #1
    Join Date
    Nov 2011
    Location
    Karlsruhe, Germany
    Posts
    57
    Thanks
    10
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Less cost by setting QWidget's background color?

    Morning all,

    i used QPalette to set the widget's background color. But the cost after that increased a lot.
    e.g from 46mb --> 55mb.

    One example to see the cost is as followed:

    Qt Code:
    1. // for testing
    2. QList<QWidget*> wList;
    3. for(int i = 0; i < 500; i++) {
    4. wList << (new QWidget());
    5. }
    To copy to clipboard, switch view to plain text mode 

    And the cost is:
    1.png

    Qt Code:
    1. for(int i = 0; i < 500; i++) {
    2. wList << (new QWidget());
    3.  
    4. wList[i]->setAutoFillBackground(true);
    5. QPalette p(wList[i]->palette());
    6. p.setColor(QPalette::Background, Qt::red);
    7. wList[i]->setPalette(p);
    8. }
    To copy to clipboard, switch view to plain text mode 

    The cost becomes:
    2.png

    So is there any way to reduce the cost?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Less cost by setting QWidget's background color?

    The task manager is not a reliable tool to measure memory usage. Besides, that's just 18kB per widget.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Setting the background color of a header in TableView
    By sunilqt in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2013, 13:06
  2. Setting Background Color
    By SixDegrees in forum Qt Programming
    Replies: 5
    Last Post: 16th February 2011, 18:33
  3. Replies: 1
    Last Post: 11th September 2009, 17:03
  4. setting background color and repositioning
    By mind_freak in forum Qt Programming
    Replies: 2
    Last Post: 11th August 2009, 06:22
  5. setting background color of QMessageBox
    By wagmare in forum Qt Programming
    Replies: 7
    Last Post: 23rd May 2009, 13:26

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.