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. QSplitter size [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

QSplitter size [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 12.9k 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.
  • Robey MardonR Offline
    Robey MardonR Offline
    Robey Mardon
    wrote on last edited by Robey Mardon
    #1

    I want to resize the QSplitter to a default position and set the minimum width/height of each one.

    The original:
    original

    The wanted:
    original

    The code:

    auto hsplitter = new QSplitter(Qt::Horizontal);
    auto vsplitter = new QSplitter(Qt::Vertical);
    
    auto listview = new QListView;
    auto treeview = new QTreeView;
    auto textedit = new QTextEdit;
    
    hsplitter->addWidget(listview);
    hsplitter->addWidget(vsplitter);
    vsplitter->addWidget(treeview);
    vsplitter->addWidget(textedit);
    
    setCentralWidget(hsplitter);
    
    1 Reply Last reply
    0
    • Robey MardonR Offline
      Robey MardonR Offline
      Robey Mardon
      wrote on last edited by
      #2

      Is there anyone that can help me with that?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stephane78
        wrote on last edited by
        #3

        Hi,
        you can try with QSplitter::setStretchFactor or QSplitter::setSizes to resize the splitter.

        Robey MardonR 1 Reply Last reply
        0
        • S stephane78

          Hi,
          you can try with QSplitter::setStretchFactor or QSplitter::setSizes to resize the splitter.

          Robey MardonR Offline
          Robey MardonR Offline
          Robey Mardon
          wrote on last edited by
          #4

          @stephane78 I tried both and doesn't work.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stephane78
            wrote on last edited by
            #5

            Hi,
            I have put for example, these 4 lines just before setCentralWidget

                hsplitter->setStretchFactor(1,3);
                vsplitter->setStretchFactor(0,2);
                vsplitter->setStretchFactor(1,1);  ```
            and it works.
            1 Reply Last reply
            1
            • S Offline
              S Offline
              stephane78
              wrote on last edited by
              #6

              HI,

              the first line of code was :

              hsplitter->setStretchFactor(0,1);
              ....
              
              1 Reply Last reply
              1
              • S Offline
                S Offline
                stephane78
                wrote on last edited by
                #7

                Hi,
                for the minimum width/height try QWidget::setMinimumSize.

                Robey MardonR 1 Reply Last reply
                1
                • S stephane78

                  Hi,
                  for the minimum width/height try QWidget::setMinimumSize.

                  Robey MardonR Offline
                  Robey MardonR Offline
                  Robey Mardon
                  wrote on last edited by
                  #8

                  @stephane78 Thank you very much, you rock. ♥

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    stephane78
                    wrote on last edited by
                    #9

                    thank you ,
                    you're welcome,

                    you can find the documentation of Qt classes on doc.qt.io if you haven't installed on your hard drive the html documentation of Qt.

                    Robey MardonR 1 Reply Last reply
                    0
                    • S stephane78

                      thank you ,
                      you're welcome,

                      you can find the documentation of Qt classes on doc.qt.io if you haven't installed on your hard drive the html documentation of Qt.

                      Robey MardonR Offline
                      Robey MardonR Offline
                      Robey Mardon
                      wrote on last edited by
                      #10

                      @stephane78 I tried to read there but I couldn't find an explanation of the usage.

                      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