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: Restrict movement after reaching a certain point
Forum Updated to NodeBB v4.3 + New Features

QSplitter: Restrict movement after reaching a certain point

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 907 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.
  • S Offline
    S Offline
    Shemp
    wrote on last edited by Shemp
    #1

    Hi, i have a problem, hope for your help. I have treeView and label above it (with vertical layout) on the left side and i have stackedWidget on the right side with tabWidget and label on it. There is a splitter between them. I want the splitter to move when the tree is resized, for example, only to the middle of the window:
    1.png
    Thus, if I move the slitter from left to right, it will only reach the middle. How to do it?
    I tried to set the maximum width for the treeView widget, but I get the following situation: the tree widget reaches its maximum width, and the splitter can be further moved to the right. It turns out empty space between widgets:
    2.png

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      Don't set the maximum width of the treeView. You need to set the splitter's direct child widget.
      Convert your vertical layout to a QWidget (in designer that's called "morph into"), and set the maximum width of it.

      [Updated]
      Ah, I just remember a way that can set the maximum size of a layout.
      You still need to set the splitter's direct child, but you can do that by setting the maximum width of the treeView.
      Then call setSizeConstraint(QLayout::SetMaximumSize) to the vertical layout, or set its layoutSizeConstraint in the designer.
      SetMinAndMaxSize should also work.

      But in my opinion the first method is still the better way.

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

        I forgot to mention - this layout is installed in the QWidget, i.e. splitter separates two widgets (QWidget, that contains vertical layout, that contains QLabel and QTreeView and QStackWidget).
        I figured out my mistake - I was setting the maximum width (setMaximumWidth) for the QTreeView object, not for the widget added to the splitter (QWidget).
        @Bonnie thank you!

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Shemp
          wrote on last edited by
          #4
          This post is deleted!
          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