Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSplitter size [SOLVED]
Qt 6.12 LTS is out! See what's new in the release blog

QSplitter size [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 13.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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #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
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Is there anyone that can help me with that?

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

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

        ? 1 Reply Last reply
        0
        • ? A Former User

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

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @stephane78 I tried both and doesn't work.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            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
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              HI,

              the first line of code was :

              hsplitter->setStretchFactor(0,1);
              ....
              
              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

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

                ? 1 Reply Last reply
                0
                • ? A Former User

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

                  ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  @stephane78 Thank you very much, you rock. ♥

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    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.

                    ? 1 Reply Last reply
                    0
                    • ? A Former User

                      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.

                      ? Offline
                      ? Offline
                      A Former User
                      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
                      • Unsolved