Font size change on different machines (QLabel inside QVBOXLayout)



  • Hi... I am using PyQT5 and QT Creator to make a GUI for use on different machines. I am using layouts for all QLabels and Qtexts. And I use screen resolution (width and height) to define each layout size:

            self.verticalLayoutWidget.setGeometry(QtCore.QRect(width /5.25, height/5.5, width/10, height/5.3))
    

    which changes the size of layout proportionally to screen resolution of current machine. But still I have issues as the everything is fine on my machine but some text inside QLabel (which is in turn inside QLayout) are incomplete on other machines (photo attached). I assume the text inside layouts should automatically change font size, but it seems that this is not happening in my case. This is how the font size is defined in my code:

            font = QtGui.QFont()
            font.setFamily("Verdana")
            font.setPointSize(10)
            self.label_15.setFont(font)
    

    Could someone please advise? Thanks.
    0_1504421185755_21297840_1643957455614803_2120863439_o.png



  • @Akzmn said in Font size change on different machines (QLabel inside QVBOXLayout):

    machine

    I think you should try setting font size to pixel size if you want it adapts to screen resolution.
    e.g., font.setPixelSize(10);



  • @Richard-Lee said in Font size change on different machines (QLabel inside QVBOXLayout):

    g., font.setPixelSize(

    Great! Thanks Richard. The only question then is: Can I use a fixed number like 10 with setPixelSize or it should also be defined relative to screen width for example (width/20)? Thanks!



  • @Akzmn Note that if you use setPixelSize() method, for the same size font, on higher resolution screen (higher density of pixels and hence smaller pixel size), it will appear smaller. Is this what you want? Or you want it appear physically the same size on screens with different resolutions?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.