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: Disable "magnetic" behavior of the handles
Forum Updated to NodeBB v4.3 + New Features

QSplitter: Disable "magnetic" behavior of the handles

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 191 Views 2 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
    stefanwoe
    wrote on last edited by stefanwoe
    #1

    I created a sample app using a vertical splitter containing 4 QListWidgets (see snippet below).
    That works as expected but if i move a splitter handle closer to the handle above or below it behaves in the following way:

    • If it drag it closer to the next handle, it will move away the next and also all following handles (OK)
    • At a certain point no handles will move any more
    • If i move it further (more than half the size of the next handle) it will collapse automatically

    What i want is, that i can resize the 4 QListWidgets without a limit - they should be shrinkable to a controllable number of pixels or at least one line. Currently i am unable to shrink them smaller than 4 Lines. I tried to use setMinimumHeight/setMinimumSize for the QListWidget - but this has no effect.

    How can this behavior be modified?
    How can i set the threshold where resizing is stopped?

    MainWindow::MainWindow(QWidget *parent)
        : QWidget(parent)
    {
        QSplitter *vSplitter = new QSplitter;
        vSplitter->setOrientation(Qt::Vertical);
    
        QListWidget *p = new QListWidget;
        p->addItems({"1", "2", "3", "4"});
        vSplitter->addWidget(p);
    
        p = new QListWidget;
        p->addItems({"1", "2", "3", "4"});
        vSplitter->addWidget(p);
    
        p = new QListWidget;
        p->addItems({"1", "2", "3", "4"});
        vSplitter->addWidget(p);
    
        p = new QListWidget;
        p->addItems({"1", "2", "3", "4"});
        vSplitter->addWidget(p);
    
        QHBoxLayout *layout = new QHBoxLayout;
        layout->addWidget(vSplitter);
        setLayout(layout);
    }
    
    

    aa71b6fa-70b5-4388-a826-bfbaf6f0b464-grafik.png

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stefanwoe
      wrote on last edited by stefanwoe
      #2

      Found the solution myself.
      Just added
      p->setMinimumSize(2, 2);
      for each QListWidget - p->setMinimumSize(0, 0); wont work as this resets the minimum Width - i was not aware of this.

      55a0621c-a147-43ff-ab00-a902a0c3f14c-grafik.png

      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