QTableView双击 单机事件信号

原文地址::http://qimo601.iteye.com/blog/1546267


相关文章

1、QT QTableView 获取单击选中行的内容----https://blog.csdn.net/wojiuguowei/article/details/71294434

2、Qt: QTableView如何获取(行)选中、行切换信息----https://blog.csdn.net/u012790503/article/details/76099587


双击QTableView的行,获取该行数据

 

代码如下,请注意参数类型匹配

 

 

Cpp代码   收藏代码
  1. connect(dataTabView_, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotRowDoubleClicked(const QModelIndex &)));  
  2.   
  3.   
  4. void ABED::rowDoubleClicked(const QModelIndex index)  
  5. {  
  6.     //通过Model获取一行  
  7.   
  8.     QModelIndex index = ui->tableView->currentIndex();  
  9.     if (index.isValid())  
  10.     {  
  11. <span style="white-space: pre;">    </span>//也可以通过自定义的Model中获取  
  12.         QSqlRecord record = model->record(index.row());  
  13.         QString value = record.value("xxxxxxx").toString();  
  14.          .................  
  15.     }  
  16. }  

 

//设定选择行为,按行选择

tableView->setSelectionBehavior(QAbstractItemView::SelectRows);


猜你喜欢

转载自blog.csdn.net/xqhrs232/article/details/80679041