• 3061阅读
  • 2回复

[提问]QTableView根据行号自动选中该行 [复制链接]

上一主题 下一主题
离线liangwenkuai
 

只看楼主 倒序阅读 楼主  发表于: 2014-07-27
请问,QTableView根据行号自动选中该行如何实现?即,现在知道QTableView的行号iRow,需要将该行选中,如何实现?》
离线dbzhang800

只看该作者 1楼 发表于: 2014-07-28
QItemSelectionModel * QAbstractItemView::selectionModel() const

通过selectionModel操作
离线liangwenkuai

只看该作者 2楼 发表于: 2014-07-28
回 dbzhang800 的帖子
dbzhang800:QItemSelectionModel * QAbstractItemView::selectionModel() const
通过selectionModel操作 (2014-07-28 00:24) 

    QItemSelectionModel *selectionModel = CConstParam::s_Ui.m_pTableView_1->selectionModel();

    QModelIndex topLeft;
    QModelIndex bottomRight;
    topLeft = CConstParam::s_pModel_1->index(0, 0, QModelIndex());
    bottomRight = CConstParam::s_pModel_1->index(5, 2, QModelIndex());

    QItemSelection selection(topLeft, bottomRight);
    selectionModel->select(selection, QItemSelectionModel::Select);
这样不行,请问具体该怎么实现?
快速回复
限100 字节
 
上一个 下一个