Home > OS >  How to set QSizePolicy in QSS stylesheet
How to set QSizePolicy in QSS stylesheet

Time:12-10

Is it possible to change the QSizePolicy property from the stylesheet?

So far I know every QWidget has the property sizePolicy. But the QSizePolicy constructor takes two arguments; so I'm not sure how to set this property from a QSS file. Also calling:

MyWidget
{
    qproperty-sizePolicy: 2; // "Expanding", Expanding, 0 0 also does not work
}

Does not seem to do anything.

CodePudding user response:

It seems it is not possible out of the box. I will have to subclass whatever QWidget I want and add two Q_PROPERTIES for each direction of the QSizePolicy. See this thread.

  • Related