简体   繁体   中英

QtDesigner setting font sizes to -1

I have used qt designer to make a ui files which I convert using pyuic5. However, the problem I am having is inside qt designer itself.

The problem

The issue I am having is when using the style sheet (set in qt designer) property of 'font-size: 36px' (or any pixel size). When I set this font-size property in the designer, the 'font' property in the designer itself is set to -1 automatically and cannot be changed. This gives the following error while the program is running QFont::setPointSize: Point size <= 0 (-1), must be greater than 0

No problems are encountered while running the program, but the error message appears very frequently which I'd like to avoid.

This answer here suggests removing the font property from the ui files themselves but I would like to avoid this if possible as I am afraid this will cause problems down the line. I have tried clicking on the option to reset the font as it suggests but the button is greyed out (it is already at default but still on -1). The answer here also says it is unrelated to the style sheets but if I remove the font-size from the style sheet the font is no longer stuck at -1. I have confirmed that this happens on different files and it happens when the stylesheet is set.

My question

So, my question is can I fix this error in the qt designer or will I have to remove the font property from my ui files.

The fix for my problem is, quite simply, using pt instead of px in the style sheet. Yep, that's it. Now to adjust all my font sizes again.

I don't know why px causes a problem in the qt designer stylesheet so if anybody reading this knows, please do share as I couldn't find an answer for that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM