Resizing the widget(listwidget)



  • Hi there, I would like to resize my whole widget(listwidget and it contains other sub widgets) to get appropriate size(1366x768) when I click the maximize .And if I click the minimize it will go back to some limited size(like 640x480) . How can I fix that here is my current code.

     auto label = new QLabel();
        label->setMinimumHeight(30);
    
        auto listWidget = new QListWidget();
        listWidget->setMinimumSize(1366,768);
    
        auto listWidget_dirList = new QListWidget();
        // listWidget_dirList->setMinimumSize(150,100);
        listWidget_dirList->setMinimumWidth(150);
    
        auto listWidget_main = new QListWidget();
        listWidget_main->setFlow(QListView::LeftToRight);
        listWidget_main->setMinimumSize(1100,768);
        listWidget_main->setGridSize(QSize(360, 360));
        listWidget_main->setResizeMode(QListView::Adjust);
        listWidget_main->setViewMode(QListView::ListMode);
        listWidget_main->setWrapping(true);
    
        auto button = new QPushButton();
        button->setText("Load Dir");
        button->setMinimumHeight(30);
    
        auto    item = new QListWidgetItem("",listWidget);
        auto    widget = new QWidget;
        auto    vb = new QVBoxLayout;
        auto    vb1 = new QVBoxLayout;
        auto    hb = new QHBoxLayout;
    
        vb->addWidget(button);
        vb->addWidget(listWidget_dirList);
    
        vb1->addWidget(label);
        vb1->addWidget(listWidget_main);
    
        hb->addLayout(vb);
        hb->addLayout(vb1);
    
        widget->setLayout(hb);
        widget->setMinimumSize(1366,768);
        listWidget->setItemWidget(item,widget);
        listWidget->show();
    

  • Moderators

    @Kinesis said in Resizing the widget(listwidget):

    listWidget->setMinimumSize(1366,768);

    Why? It should be resizeable, right?

    widget->setMinimumSize(1366,768);

    Again: why?

    Your "widget" isn't in any layout as far as I can see. And did you call widget->show() somewhere?



  • @jsulm
    "Why? It should be resizeable, right?"
    Ans:: Yes it should be resizeable.So I just need to unable this resize function?

    "Your "widget" isn't in any layout as far as I can see. And did you call widget->show() somewhere?"
    Ans:: I add label , button , listwidget_dirlist and listwidget_main on listWidget . And I call listWidget->show();


  • Moderators

    @Kinesis I don't think you need these setMinimumSize(1366,768).

    " I add label , button , listwidget_dirlist and listwidget_main on listWidget . And I call listWidget->show();" - I'm talking about "widget" variable, not listWidget.



  • @jsulm said in Resizing the widget(listwidget):

    I'm talking about "widget" variable, not listWidget.

    As you can see in the code I said variable "auto listWidget = new QListWidget" .


  • Moderators

    @Kinesis

    auto    widget = new QWidget;
    


  • @jsulm
    Ahh ok. How can I resize the vertical box ? I want its width to be thinner that I can see slider bar . When I use 1366x768 the vertical box vb(variable) becomes wider and I can't see the slider which is at the right edge of my widget.


  • Moderators

    @Kinesis said in Resizing the widget(listwidget):

    When I use 1366x768

    Why do you set 1366x768?
    If you're using layouts properly there is no need for that.
    I already asked before: did you put widget in a layout?



  • This post is deleted!


  • @jsulm
    I got this, thanks



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