当前位置:网站首页>QT tablewidget determines whether a row is selected and obtains the data of the selected row
QT tablewidget determines whether a row is selected and obtains the data of the selected row
2022-07-21 09:41:00 【Pointer loves me again】
Qt tablewidget Judge whether a row is selected and obtain the data of the selected row
Look directly at the code :
1. Get all column data of the selected row
QList<QTableWidgetItem*> items = ui->tableWidget->selectedItems();
int count = items.count();
for(int i = 0; i < count; i++)
{
int row = ui->tableWidget->row(items.at(i));
QTableWidgetItem *item = items.at(i);
QString text = item->text(); // Get content
}
2. Get the first column data of the selected row and judge whether a row is selected
QList<QTableWidgetItem*> items = ui->tableWidget_5->selectedItems();
if(!items.empty()){
int count = items.count();
QTableWidgetItem *item = items.at(0);
QString borrow_id= item->text();
qDebug()<<borrow_id;
}
else{
QMessageBox::warning(this," Warning "," Please select a row before operation ");
}
notes : Judge whether a line is selected :
QList<QTableWidgetItem*> items = ui->tableWidget_5->selectedItems();
if(!items.empty())
qDebug()<<" A row is selected ";
else
QMessageBox::warning(this," Warning "," Please select a row before operation ");
边栏推荐
- DOS汇编分支、循环编程与寄存器分析
- 我是如何毕业就失业的?
- C language: preprocessing
- 乐观锁悲观锁适用场景
- Chinese scientists have made new progress in high security quantum key distribution networks
- C#递归获取文件夹下所有文件 并绑定到 TreeView控件中
- How is the income calculated when the financial product expires?
- DOS assembly debug basic command and its function explanation
- 教育事件
- js 验证只能输入数字和一个小数点
猜你喜欢
随机推荐
How to use node JS access data in SAP Hana cloud database
vscode安装及配置
常用的锂电池升压IC
Several ways to open SAP Hana Database Explorer in different locations
vector、queue、stack用法详解
瓜分30万奖金!DeepRec CTR模型性能优化天池挑战赛来啦
MySQL乐观锁
A specific example of using SAP ui5 system testing tool uiveri5
MySQL optimistic lock
哪些自动化工具赋能电商运营效率翻倍?
thinkphp5中使用phpmailer实现发送邮件功能
Common lithium battery boost IC
【HMS core】【push kit】【FAQ】华为推送服务 手机未收到推送消息/消息延迟/息屏通知 问题合集
微处理器原理之数值转换练习与解答
Codeforces Round #650 (Div. 3)ABCD题解
rank函数的功能有哪些
在 SAP Business Application Studio 里访问 SAP HANA Cloud 实例
茶叶的基本功效
【组成原理 五 系统总线】
重磅预告!易观分析联合微软、中央财经大学,共话数字经济