5

I'm using Qt 4.6.2 and i have problem with QCSS. I have own Q_PROPERTY(QFont myFont READ myFont SET setMyFont). I want to change it with QCSS but it doesn't work. I've tried using normal font syntax but it doesn't work. I've also tried few other combinations like:

qproperty-myFont: font(serif 20 1 0) font(serif 20 bold) QFont(serif 20 1 0) QFont(serif 20 bold) QFont(bold 20px serif)

etc.

Kamil Klimek
  • 12,884
  • 2
  • 43
  • 58

1 Answers1

10

Ok, after longer research i found methods QFont::toString and QFont::fromString. It's not so clean and "css nice style" but it works now:

qproperty-myFont: "serif,-1,14,5,0,0,0,0,0,0";

Where parameters are: font family, pointSizeF, pixelSize, QFont::StyleHint, QFont::Weight, QFont::Style, underline, strikeOut, fixedPitch, rawMode

Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
Kamil Klimek
  • 12,884
  • 2
  • 43
  • 58
  • A note: often (i.e. when there's only one font used) you can get away with using the QWidget's `font` property, which is supported in stylesheets with that nice syntax. – mlvljr Jun 01 '13 at 19:09