#include <QApplication> #include <QFont> #include <QTextEdit> #include <QSplitter> int main(int argc, char *argv[]) { QApplication a(argc, argv); QSplitter *splitterMain = new QSplitter(Qt::Horizontal, 0); QTextEdit *textLeft = new QTextEdit("Left", splitterMain); //splitterMain->setDisabled(true); //设置是否可移动 textLeft->setAlignment(Qt::AlignCenter); QSplitter *splitterRight = new QSplitter(Qt::Vertical, splitterMain); //splitterRight->setDisabled(true); QTextEdit *textTop = new QTextEdit("top", splitterRight); textTop->setAlignment(Qt::AlignCenter); QTextEdit *textButton = new QTextEdit("bottom", splitterRight); textButton->setAlignment(Qt::AlignCenter); splitterMain->setStretchFactor(0, 1); splitterMain->setStretchFactor(1, 1); splitterMain->setWindowTitle("hi"); splitterMain->show(); return a.exec(); }