Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Font size change on different machines (QLabel inside QVBOXLayout)
Forum Updated to NodeBB v4.3 + New Features

Font size change on different machines (QLabel inside QVBOXLayout)

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 2 Posters 5.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Akzmn
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Richard Lee
      wrote on last edited by
      #2

      @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);

      A 1 Reply Last reply
      2
      • R Richard Lee

        @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);

        A Offline
        A Offline
        Akzmn
        wrote on last edited by
        #3

        @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!

        R 1 Reply Last reply
        0
        • A Akzmn

          @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!

          R Offline
          R Offline
          Richard Lee
          wrote on last edited by
          #4

          @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?

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved