Qt - Making a Splitter Horizontal and Vertical at same time

后端 未结 1 1019
不知归路
不知归路 2021-02-08 01:09

I have a QGridLayout with a QSplitter on it. In that QSplitter I have two elements with a splitter that lets me move the splitter from lef

相关标签:
1条回答
  • 2021-02-08 01:46

    You should be able to adapt this for your needs easily. The idea is to create a container for the first two elements, then connect the container with the 3rd element all via 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();
    
    
    }
    
    0 讨论(0)
提交回复
热议问题