Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. scaledContents Equivalent for QComboBox
Forum Updated to NodeBB v4.3 + New Features

scaledContents Equivalent for QComboBox

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 610 Views 2 Watching
  • 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.
  • B Offline
    B Offline
    Burke212
    wrote on last edited by Burke212
    #1

    As I have been working on my application I've noticed many of the text elements in widgets (e.g. QComboBox, QPushButton...) don't resize if the window resizes.

    For example, when my application initially runs it's smaller than my screen size. When I maximize the application, the window is exactly the size of my screen, and the widgets resize & adjust accordingly, but the font/ text remains the same size.

    QLabel has the "scaledContents(bool)" property. From the doc, I believe this is exactly what I need, but for QComboBox.

    Is there anything that is similar or will produce the same result for QComboBox that scaledContents(bool) does for QLabel? How can I adjust the size of the font/ text when the widget resizes?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Sadly no.
      Qt has font scaling when using different DPI screens
      http://doc.qt.io/qt-5/highdpi.html
      but Qt will not adjust the point size on resizing the parent window.
      If you wish to have say a combobox use more width, you have to use something like
      QFontInfo to calculate manually a new font point size for it to use.

      1 Reply Last reply
      3
      • B Offline
        B Offline
        Burke212
        wrote on last edited by
        #3

        That is interesting. I can't help but think that Qt has some way of accomplishing this.

        Maybe this example will help:
        In the image below, the text "Down The Rabbit Hole I Go" has a size; lets call it X. This window is not in Maximized mode.
        0_1549470960438_min.PNG

        Now in this image, the same text seems to have a smaller size than X. This window is in Maximized mode.
        0_1549471078568_max.PNG

        So, when the window is maximized, the text adjusts to the new dimensions. This is similar to what I am trying to accomplish.

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          Well its possible to calculate your self and adjust the font for the combo box.
          However, its purely manual code.

          1 Reply Last reply
          0

          • Login

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