With Qt, should I use setStyleSheet or QPalette(Background, image) for setting up a background image?

StackOverflow https://stackoverflow.com/questions/14034824

I am fairly new to developing with Qt. I've been reading quite a lot in the past week and have heard that sometimes setting up background images with Style Sheets cause "slowing down" problems.

Being the genius that I am (sarcasm) I figured how to set backgrounds using QPalette.setBrush() method.

My question is:

  • When setting up a background image to a QWidget, QScrollArea etc, which method should I use for the best performance (and if matters, low memory foot-print).

If it helps, the image I am using repeats itself.

有帮助吗?

解决方案

In this case, using setBrush is faster than using style sheets.

Usage of style sheets often leads to poor UI performance and increases start time. Also style sheets have some limitations, for example, no transparent list or tree views AFAIR.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top