PDA

View Full Version : Less cost by setting QWidget's background color?



cic
11th September 2013, 09:22
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:




// for testing
QList<QWidget*> wList;
for(int i = 0; i < 500; i++) {
wList << (new QWidget());
}


And the cost is:
9568



for(int i = 0; i < 500; i++) {
wList << (new QWidget());

wList[i]->setAutoFillBackground(true);
QPalette p(wList[i]->palette());
p.setColor(QPalette::Background, Qt::red);
wList[i]->setPalette(p);
}


The cost becomes:
9569

So is there any way to reduce the cost?

wysota
11th September 2013, 10:24
The task manager is not a reliable tool to measure memory usage. Besides, that's just 18kB per widget.