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. how to limit QListWiget height?
Qt 6.11 is out! See what's new in the release blog

how to limit QListWiget height?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • chaochaoC Offline
    chaochaoC Offline
    chaochao
    wrote on last edited by
    #1

    Now I new a QListWiget just with four items . But it's height always equal to window's height. I want to limit it's height by four items's totall height . I have tyied stylesheet ,resize ,but it can not work.

    _listwidget->addItem(tr("ALL"));
    _listwidget->addItem(tr("Prefer));
    _listwidget->addItem(tr("Current"));
    _listwidget->addItem(tr("Rcent"));

    QGridLayout *layout = new QGridLayout;
    layout->setColumnStretch(0,1);
    layout->setColumnStretch(1,3);
    layout->addWidget(_listwidget,0,0,1,1);
    layout->addLayout(_stacklayout,0,1,3,1);
    layout->addWidget(_infowidget,1,0,2,1);

    if don't limit the listwidget height, _infowidget can not display.Thank for you help.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2
      _listwidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
      _listwidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Maximum);
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      chaochaoC 1 Reply Last reply
      1
      • VRoninV VRonin
        _listwidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
        _listwidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Maximum);
        
        chaochaoC Offline
        chaochaoC Offline
        chaochao
        wrote on last edited by
        #3

        @VRonin thanks

        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