Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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