- Table Model
- Qt’s model/view architecture # Qt’s model hierarchy # 关联Table Model中的数据到QComboBox,并过滤重复数据 # void MainWindow::createComboBoxModel(QComboBox *comboBox, int column) { delete comboBox->model(); UniqueProxyModel *uniqueProxyModel = new UniqueProxyModel(column,this); uniqueProxyModel->setSourceModel(model); uniqueProxyModel->sort(column, Qt::AscendingOrder); comboBox->setModel(uniqueProxyModel); comboBox->setModelColumn(column); } 清除QTableView中的选择 # QItemSelectionModel *selectionModel = tableView->selectionModel(); selectionModel->clearSelection(); QItemSelection和QItemSelectionModel进行任意行组合选择 # QItemSelection selection; int firstSelectedRow = -1; for (int row = 0; row < proxyModel->rowCount(); ++row) { QModelIndex index = proxyModel->index(row, Zipcode); QItemSelection rowSelection(index, index); selection.
- Tree Model
Advanced Qt Programming