Search code examples
qtqsplitter

QSplitter in two directions


I want to make an app that includes four widgets that are resizable using QSplitter. In this app I would like that all four widgets are resized when I resize the splitter. I realised this by having a horizontal splitter contain two vertical splitters. This way however the vertical splitting only concerns two widgets and not all four. Is there a way to to this "matrix" splitting?


Solution

  • Have you tried connecting the splitterMoved(int,int) signal of one to the moveSplitter(int,int) slot of the other?

    QObject::connect(ui->upperSplitter, SIGNAL(splitterMoved(int,int), ui->lowerSplitter, SLOT(moveSplitter(int,int));
    QObject::connect(ui->lowerSplitter, SIGNAL(splitterMoved(int,int), ui->upperSplitter, SLOT(moveSplitter(int,int));
    

    http://doc.qt.io/qt-5/qsplitter.html#splitterMoved

    http://doc.qt.io/qt-5/qsplitter.html#moveSplitter

    Or you may have to look at the QSplitterHandle class.

    http://doc.qt.io/qt-5/qsplitterhandle.html

    Hope that helps.