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.

1 Answer 1

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 :/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.