Program-Me-Rev
Program-Me-Rev

Reputation: 6624

How to add multiple Style Classes to a QtWidget

I add a Style class to a Qt widget as follows:

minimizeApp = new QPushButton();
minimizeApp -> setProperty("class", "undecorated-widgets");

The problem I'm having is that I can only add one style class to an element. If I try adding a second one the previous one gets lost.

How can I add multiple style classes to an element?

In Java this is possible through:

label.getStyleClass().addAll("style-class-1", "style-class-2", "......");

Is this possible in Qt?

Upvotes: 1

Views: 182

Answers (1)

Andrew Leedham
Andrew Leedham

Reputation: 718

I would imagine the setProperty function sets the class attribute directly, so separating them with spaces like you would in html should work.

minimizeApp = new QPushButton();
minimizeApp -> setProperty("class", "undecorated-widgets second-class third-class");

Upvotes: 3

Related Questions