Updating fixed window size



  • 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)?



  • 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();
    }
    

    @



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



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


Log in to reply
 

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