2

After a lot of research I finally realized that my application is looking funny because the fonts specified in Qt Creator are in points and not in pixels, and my laptop is running at 125% scale.

Is there a way in which I can change Qt Creator behaviour so it uses pixels instead of points for font sizes? So I don't have to manually edit the .ui files to change "pt" for "px". I'm using PyQt5.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Rafael Boy
  • 287
  • 2
  • 8

1 Answers1

0

changing the tags in the ui files from something like <pointsize>12</pointsize> to <pixelsize>16</pixelsize> sadly results in a qmake error. Hence I take it that the font size cannot be set in pixel at all.

you can set the font size in C (and probably also python) using something like setPixelSize(something_pt) instead of setPointSize(someting_px)

However you can set the conversion factor that qt will use when drawing fonts with export QT_FONT_DPI=72

Since a point is 3.52806mm or 1/72 inch. if you set QT_FONT_DPI to 72 the point-size will match the pixel-size.

Sadly that doesn't play well together with QT_SCALE_FACTOR though :/

Maximilian
  • 76
  • 5