Qt中分割窗口

#include 
#include 

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QFont font("ZYSong18030", 12);  //字体
    a.setFont(font);    //主程序设置字体
    //主分割窗口
    QSplitter* pMainSplitter = new QSplitter(Qt::Horizontal, 0);    //水平分割窗口
    QTextEdit* pText1 = new QTextEdit(QStringLiteral("1"), pMainSplitter);  //主窗口显示文字
    pText1->setAlignment(Qt::AlignCenter);  //文字居中

    //右分割窗口
    QSplitter* pRightSplitter = new QSplitter(Qt::Vertical, pMainSplitter); //垂直分割窗口:父窗口为pMainSplitter
    pRightSplitter->setOpaqueResize(false); //拖动时分割条不实时显示
    QTextEdit* pText2 = new QTextEdit(QStringLiteral("2"), pRightSplitter); //主窗口显示文字
    pText2->setAlignment(Qt::AlignCenter);  //文字居中
    QTextEdit* pText3 = new QTextEdit(QStringLiteral("3"), pRightSplitter); //主窗口显示文字
    pText3->setAlignment(Qt::AlignCenter);  //文字居中

    pMainSplitter->resize(800, 600);    //设置窗口大小
    pMainSplitter->show();  //显示分割窗口
    //Splitter w;
    //w.show();
    return a.exec();
}

你可能感兴趣的:(Qt中分割窗口)