Skip to content
  • 0 Votes
    11 Posts
    428 Views
    SGaistS

    Hi,

    System styles such as those from Windows and macOS ignore certain hints and draw controls as expected for these platforms. Qt follows the platform user interface guidelines closely to ensure that applications looks as expected.

  • Understanding QPalette

    Solved General and Desktop
    7
    0 Votes
    7 Posts
    634 Views
    Axel SpoerlA

    @tim-hilt Can you describe verbally which palette should be changed? The application palette? A specific widget’s palette? Something else? We’ll find it out!

  • 0 Votes
    1 Posts
    567 Views
    No one has replied
  • 0 Votes
    3 Posts
    3k Views
    raven-worxR

    @ericg22
    You can simply set properties of widgets via QSS. Most basic types are parsed. Even enums can be used by name when registered to the meta system.

    class MyWidget : public QWidget { Q_OBJECT Q_PROPERTY( QColor CustomColor READ ... WRITE ... DESIGNABLE true ) Q_RPOPERTY( QFont CustomFont READ ... WRITE ... DESIGNABLE true ) Q_PROPERTY( QString CustomString READ ... WRITE ... DESIGNABLE true ) Q_PROPERTY( int CustomInteger READ ... WRITE ... DESIGNABLE true ) Q_PROPERTY( QIcon CustomIcon READ ... WRITE ... DESIGNABLE true ) Q_PROPERTY( MyEnum CustomEnum READ ... WRITE ... DESIGNABLE true ) Q_ENUMS( MyEnum ) ... enum MyEnum { MyEnumValue1, MyEnumValue2 } }

    example qss to set properties:

    MyWidget { qpropert-CustomColor: rgba(...); //also rgb(), hsv(), rgba(), named-colors, #XXXXXX, etc. are possible9 qproperty-CustomFont: "serif,-1,14,5,0,0,0,0,0,0"; // see QFont::fromString(): Font-Family, pointSizeF, pixelSize, QFont::StyleHint, QFont::Weight, QFont::STyle, underline, strikeout, fixedPitch, rawMode qproperty-CustomFont: "Times New Roman,12"; //should also be possible qproperty-CustomString: "Any string..."; qproperty-CustomInt: 8253; qproperty-CustomIcon: url(:/path/to/qrc/resource/icon.png); qproperty-CustomEnum: MyEnumValue2; }