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. is there anybody to explain of sizepolicy?
Qt 6.11 is out! See what's new in the release blog

is there anybody to explain of sizepolicy?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.3k 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
    choiinkuk
    wrote on last edited by choiinkuk
    #1

    i worte some test code to understand different of sizepolicy.


    QHBoxLayout *layout = new QHBoxLayout();
    layout->setContentsMargins(0,0,0,0);
    
    QPushButton *button1 = new QPushButton("minimun", this);
    button1->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    
    QPushButton *button2 = new QPushButton("preferred", this);
    button2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    
    QPushButton *button3 = new QPushButton("maximum", this);
    button3->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
    
    layout->addWidget(button1);
    layout->addWidget(button2);
    layout->addWidget(button3);
    
    this->setLayout(layout);
    

    Alt text

    i know difference of maximum and minimum,
    but i don't understand difference of minimum and preferred,
    because the stretching behavior of minimum is as same as it of preferred.

    i did read manpage serveral time, but i can't understand.

    is there anybody to explain of sizepolicy?

    thank you.

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi, and welcome to the Qt Dev Net!

      • Minimum: The widget is not allowed to be smaller than its sizeHint().
      • Preferred: The widget is allowed to be smaller than its sizeHint().

      This is described at http://doc.qt.io/qt-5/qsizepolicy.html#Policy-enum

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      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