how to limit QListWiget height?



  • 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.



  • _listwidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
    _listwidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Maximum);
    


  • @VRonin thanks


Log in to reply
 

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