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. Resizing the widget(listwidget)
QtWS25 Last Chance

Resizing the widget(listwidget)

Scheduled Pinned Locked Moved Solved General and Desktop
qtcreatorsizepolicyresizelistwidget
10 Posts 2 Posters 4.2k Views
  • 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 Offline
    K Offline
    Kinesis
    wrote on last edited by
    #1

    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();
    
    jsulmJ 1 Reply Last reply
    0
    • K Kinesis

      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();
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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
      0
      • jsulmJ jsulm

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

        K Offline
        K Offline
        Kinesis
        wrote on last edited by
        #3

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

        jsulmJ 1 Reply Last reply
        0
        • K Kinesis

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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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
          0
          • jsulmJ jsulm

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

            K Offline
            K Offline
            Kinesis
            wrote on last edited by
            #5

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

            jsulmJ 1 Reply Last reply
            0
            • K Kinesis

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

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Kinesis

              auto    widget = new QWidget;
              

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

              K 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Kinesis

                auto    widget = new QWidget;
                
                K Offline
                K Offline
                Kinesis
                wrote on last edited by
                #7

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

                jsulmJ 1 Reply Last reply
                0
                • K Kinesis

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

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @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
                  0
                  • jsulmJ jsulm

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

                    K Offline
                    K Offline
                    Kinesis
                    wrote on last edited by
                    #9
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • jsulmJ jsulm

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

                      K Offline
                      K Offline
                      Kinesis
                      wrote on last edited by
                      #10

                      @jsulm
                      I got this, 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