开发者

Showing data on QTableWidget

开发者 https://www.devze.com 2022-12-29 18:06 出处:网络
I have a database table and I must read it and show it on tableWidget I read it but I cant show it on tableWidget, How开发者_运维技巧 can I do?

I have a database table and I must read it and show it on tableWidget

I read it but I cant show it on tableWidget, How开发者_运维技巧 can I do?

Thanks


There is no function biding datable table with QTableWidget. So you must get data from datable and set it on QTableWitget by using QTableWidgetItem. You must set data on QTableWidget's cells manually.

 QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
     data);
 tableWidget->setItem(row, column, newItem);

Regards!


There is a class which designed to be used with QTableView widget which takes data from the database: http://doc.qt.io/archives/4.6/qsqltablemodel.html

0

精彩评论

暂无评论...
验证码 换一张
取 消