Qt - creating a horizontal and vertical splitter at the same time

I have a QGridLayout with a QSplitter on it. In this QSplitter , I have two separator elements that allows me to move the splitter from left to right. Well, everything is in order there. But then I want to add another splitter, but it moves down. (I will explain with the image.)

split window with two boxes atop a single wide box

Thus, it basically has 2 splitters, one of which moves from left to right and the other that moves up and down.

I hope you understand.

 QGridLayout *layout = new QGridLayout(this); QSplitter *splitter = new QSplitter(); text1 = new QPlainTextEdit(); text2 = new QPlainTextEdit(); splitter->addWidget(text1); splitter->addWidget(text2); text1->resize(800, this->height()); layout->addWidget(splitter, 1, 0); browser = new QTextBrowser(); browser->resize(1, 1); layout->addWidget(browser, 2, 0); setLayout(layout); 

Here I add only 1 splitter, because I do not know how to make a second one.

+7
source share
1 answer

You should easily adapt this for your needs. The idea is to create a container for the first two elements, and then connect the container to the third element through splitters.

 #include <QtGui> int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget wnd; QTextEdit *editor1 = new QTextEdit; QTextEdit *editor2 = new QTextEdit; QTextEdit *editor3 = new QTextEdit; QSplitter *split1 = new QSplitter; QSplitter *split2 = new QSplitter; QVBoxLayout *layout = new QVBoxLayout; QWidget *container = new QWidget; QVBoxLayout *container_layout = new QVBoxLayout; split1->addWidget(editor1); split1->addWidget(editor2); container_layout->addWidget(split1); container->setLayout(container_layout); split2->setOrientation(Qt::Vertical); split2->addWidget(container); split2->addWidget(editor3); layout->addWidget(split2); wnd.setLayout(layout); wnd.show(); return app.exec(); } 
+15
source

All Articles