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

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

Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top