Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Resizing the widget(listwidget)

    General and Desktop
    qtcreator sizepolicy resize listwidget
    2
    10
    2833
    Loading More Posts
    • 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.
    • K
      Kinesis last edited by

      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();
      
      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @Kinesis last edited by

        @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?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        K 1 Reply Last reply Reply Quote 0
        • K
          Kinesis @jsulm last edited by

          @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();

          jsulm 1 Reply Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion @Kinesis last edited by

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

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            K 1 Reply Last reply Reply Quote 0
            • K
              Kinesis @jsulm last edited by

              @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" .

              jsulm 1 Reply Last reply Reply Quote 0
              • jsulm
                jsulm Lifetime Qt Champion @Kinesis last edited by

                @Kinesis

                auto    widget = new QWidget;
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                K 1 Reply Last reply Reply Quote 0
                • K
                  Kinesis @jsulm last edited by

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

                  jsulm 1 Reply Last reply Reply Quote 0
                  • jsulm
                    jsulm Lifetime Qt Champion @Kinesis last edited by

                    @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?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    K 2 Replies Last reply Reply Quote 0
                    • K
                      Kinesis @jsulm last edited by

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • K
                        Kinesis @jsulm last edited by

                        @jsulm
                        I got this, thanks

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post