Purpose of sizeHint() and minimumSizeHint() ? (solved)

  • What is the purpose of sizeHint() and minimumSizeHint() ?
    I see it often in widget class
    QSize LED ::sizeHint() const{
    return QSize(diamX_ , diamY_);

    QSize LED ::minimumSizeHint() const {
    return QSize(diamX_, diamY_);

  • Qt Champions 2017

    sizeHint : const QSize
    This property holds the recommended size for the widget.

    minimumSizeHint : const QSize
    This property holds the recommended minimum size for the widget.

  • So which function takes precedence? sizeHint or minimumSizeHint
    Or user have to explicitly call either function?

  • Qt Champions 2017


    Both are used
    When the widget is created the system uses sizeHint for how to big to make at start.
    When the widget is resized ( by layout, by user dragging) the minimumSizeHint is used to
    make sure it never becomes smaller than that.

Log in to reply

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