#include <QApplication>
#include <QSplitter>
#include <QLabel>
#include <QWidget>
#include <QHBoxLayout>
#include <QTextEdit>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
QSplitter *splitter = new QSplitter(Qt::Horizontal, &window);
//// 创建两个子 QLabel
QLabel *label1 = new QLabel("Child Widget 1",&window);
QLabel *label2 = new QLabel("Child Widget 2",&window);
QPalette sample_palette;
sample_palette.setColor(QPalette::Window, Qt::white);
sample_palette.setColor(QPalette::WindowText, Qt::blue);
label1->setAutoFillBackground(true);
label1->setPalette(sample_palette);
label2->setStyleSheet("QLabel { background-color : red; color : blue; }");
splitter->addWidget(label1);
splitter->addWidget(label2);
QHBoxLayout * hBox = new QHBoxLayout(&window);
hBox->addWidget(splitter);
window.show();
return app.exec();
}