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++) {
}
// for testing
QList<QWidget*> wList;
for(int i = 0; i < 500; i++) {
wList << (new QWidget());
}
To copy to clipboard, switch view to plain text mode
And the cost is:
1.png
for(int i = 0; i < 500; i++) {
wList[i]->setAutoFillBackground(true);
p.
setColor(QPalette::Background, Qt
::red);
wList[i]->setPalette(p);
}
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);
}
To copy to clipboard, switch view to plain text mode
The cost becomes:
2.png
So is there any way to reduce the cost?
Bookmarks