刚学Qt新手,望各位高手帮帮忙.........在这里先谢了......
Qt 4.4.3中在addressbook 的例子里,我在原来的新增对话框里面添加了一个QComboBox,并添加几项如( 同学,朋友,同事...) 在把tab Widget的页标签改成同样的类型````````
请问一下怎样在新增的时候 (选择某类型后) 将数据存储在相应类型的页标签视图中???备注:原来没有下拉列表时是按名字的首字母与标签中字母比较在存储的.`````原来.部分代码如下:[
void AddressWidget::setupTabs()
{
QStringList groups;
groups << "ABC" << "DEF" << "GHI" << "JKL" << "MNO" << "PQR" << "STU" << "VW" << "XYZ";
for (int i = 0; i < groups.size(); ++i) {
QString str = groups.at(i);
proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(table);
proxyModel->setDynamicSortFilter(true);
QTableView *tableView = new QTableView;
tableView->setModel(proxyModel);
tableView->setSortingEnabled(true);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->horizontalHeader()->setStretchLastSection(true);
tableView->verticalHeader()->hide();
tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
tableView->setSelectionMode(QAbstractItemView::SingleSelection);
QString newStr = QString("^[%1].*").arg(str);
proxyModel->setFilterRegExp(QRegExp(newStr, Qt::CaseInsensitive));
proxyModel->setFilterKeyColumn(0); proxyModel->sort(0, Qt::AscendingOrder);
connect(tableView->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
this, SIGNAL(selectionChanged(const QItemSelection &)));
addTab(tableView, str);
}
}
[ 此帖被hx860812在2009-03-20 10:19重新编辑 ]