Artis De Partis
Artis De Partis

Reputation: 321

Qt QGraphicsView and StyleSheets

Can I use CSS/stylesheets to style a item in QGraphicsView, like QGraphicsWidget? If yes, how?

Upvotes: 4

Views: 3461

Answers (1)

SingerOfTheFall
SingerOfTheFall

Reputation: 29966

I don't think it's directly possible, at least if you apply a stylesheet to the QGraphicsView itself it will not affect any widgets inside of it. However, you can assign a stylesheet to a widget before adding it into the scene, then it will keep it's style after being added:

QGraphicsScene scene;
QPushButton b;

b.setStyleSheet("QPushButton{background-color:red}");
scene.addWidget(&b);

QGraphicsView view(&scene);
view.show();

Upvotes: 1

Related Questions