Qt中splitter的使用

QSplitter *splitter1=new QSplitter(Qt::Horizontal);
    QTreeWidget *treeWidget=new QTreeWidget;
    treeWidget->setColumnCount(1);
    QString Header="Folders";
    treeWidget->setHeaderLabel(Header);
    QStringList first;
    first<<"Mail";
    QTreeWidgetItem *firstRoot=new QTreeWidgetItem(treeWidget,first);

    QStringList second1;
    second1<<"Inbox";
    QTreeWidgetItem *secondRoot1=new QTreeWidgetItem(firstRoot,second1);

    QStringList second2;
    second2<<"Outbox";
    QTreeWidgetItem *secondRoot2=new QTreeWidgetItem(firstRoot,second2);

    QStringList second3;
    second3<<"Sent";
    QTreeWidgetItem *secondRoot3=new QTreeWidgetItem(firstRoot,second3);

    QStringList second4;
    second4<<"Trash";
    QTreeWidgetItem *secondRoot4=new QTreeWidgetItem(firstRoot,second4);

    QTreeWidget *treeWidget2=new QTreeWidget;
    QTextEdit *edit1=new QTextEdit;
    edit1->setText("The First");
    QTextEdit *edit2=new QTextEdit;
    edit2->setText("The Second");
    QSplitter *splitter=new QSplitter(Qt::Vertical);
    splitter->addWidget(treeWidget2);
    splitter->addWidget(edit1);
    splitter->addWidget(edit2);
    splitter1->addWidget(treeWidget);
    splitter1->addWidget(splitter);

    splitter1->show();

Qt中splitter的使用_第1张图片

你可能感兴趣的:(Qt学习)