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. Updating fixed window size
Qt 6.11 is out! See what's new in the release blog

Updating fixed window size

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.1k Views 1 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.
  • C Offline
    C Offline
    Chris H
    wrote on last edited by
    #1

    I've got a magnification setting for my otherwise fixed-size window:
    @void MainWindow::SetWidgetSizes ()
    {
    QFont normal (_labelStarted->font ());
    normal.setPointSizeF (_magnification*11);
    _labelStarted->setFont (normal);
    _labelStarted->updateGeometry ();
    setFixedSize (sizeHint().width(), sizeHint().height());
    }@
    I call this function every time I change the magnification. The text size of the widget changes, but the size of MainWindow doesn't. What do I need to do to get sizeHint() to give the new, updated preferred size for the layout (or to get the layout to recalculate its preferred size)?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      joonhwan
      wrote on last edited by
      #2

      did you try following?

      @
      void MainWindow::SetWidgetSizes ()
      {
      QFont normal (_labelStarted->font ());
      normal.setPointSizeF (_magnification*11);
      _labelStarted->setFont (normal);
      _labelStarted->updateGeometry ();
      setFixedSize (sizeHint().width(), sizeHint().height());

          this->updateGeometry();
      }
      

      @

      joonhwan at gmail dot com

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chris H
        wrote on last edited by
        #3

        Yeah—no luck. The problem appears to be that sizeHint() is not changing when I change the label size.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          joonhwan
          wrote on last edited by
          #4

          Sounds like i was misunderstood.
          it seems that it is needed to change centeral widget's size hint, though.

          joonhwan at gmail dot com

          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