Honza
Honza

Reputation: 1008

Change color of QGraphicsView rubber band

I know it's possible to change color of the rubber band rectangle this way:

QRubberBand rubberBand = new QRubberBand(QRubberBand::Rectangle, this);

QPalette pal;
pal.setBrush(QPalette::Highlight, QBrush(Qt::white));
rubberBand->setPalette(pal);

But is here any way to achieve this for rubber band, which is rendered by QGraphicsView when RubberBandDrag mode is active? Or do it in some "global scope"?

Upvotes: 1

Views: 1350

Answers (1)

Honza
Honza

Reputation: 1008

I'm sorry I wrote this question, but I've looked for the solution very long time, and nothing. But few minutes after asking, I found solution by setting the stylesheet. So I'm sharing it.

Just go into the designer of the Qt Creator, click on your canvas (QGraphicsView). In the "QWidget" part find "styleSheet", edit it, and put something like:

selection-background-color: rgba(255, 255, 255, 128);

That's it :-). Thanks.

Upvotes: 3

Related Questions