My splitter has two widgets. Both should be the central. The splitter is added to a layout.
My code as below: (Do note that the code exists in the constructor of a class inheriting a QWidget)
splitter = new QSplitter(Qt::Horizontal);
treeItem = new QTreeView;
listItem = new QListView;
QList<int> sizes;
sizes.append(200);
sizes.append(600);
splitter->addWidget(treeItem);
splitter->addWidget(listItem);
splitter->setSizes(sizes);
splitter->setStretchFactor(0, 1);
splitter->setStretchFactor(1, 1);
QVBoxLayout *layoutMain = new QVBoxLayout;
layoutMain->setContentsMargins(0, 0, 0, 0);
layoutMain->addWidget(splitter);
layoutMain->addStretch();
setLayout(layoutMain);
showMaximized();





Reply With Quote
Bookmarks