QSplitter* spt = new QSplitter(Qt::Horizontal);QTableView *view = new QTableView;QSqlTableModel* model = new QSqlTableModel; ..........................view->setModel(model);spt->addWidget(view);setCentralWidget(spt);
C++ (Qt)QSplitter* spt = new QSplitter(Qt::Horizontal, this);QTableView *view = new QTableView(this);QSqlTableModel* model = new QSqlTableModel(this);
...................... QHBoxLayout* mainLayout = new QHBoxLayout; view->setModel(model); spt->addWidget(view); mainLayout->addWidget(spt); setLayout(mainLayout);
C++ (Qt)class MainWindow : public QMainWindow{public: MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0) : QMainWindow(parent, flags) { QSplitter *splitter = new QSplitter(this); QTableView *tableView = new QTableView(this); QFileSystemModel *model = new QFileSystemModel(this); model->setRootPath("/"); tableView->setModel(model); splitter->addWidget(tableView); splitter->addWidget(new QTableWidget(1, 1, this)); setCentralWidget(splitter); }};