-1

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

ayla
  • 377
  • 4
  • 7
  • 14
  • 2
    @ayla Please, don't make trash from stackoverflow. All you previous questions and this one is the basic questions, and if you look in few Qt books (or Google), you quickly find what you need. Also you can find answers on your questions in *Qt Assistent* & *Qt Demo* applications. They are created specially for that cases. – mosg May 07 '10 at 08:21

2 Answers2

1

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

Christophe Weis
  • 2,518
  • 4
  • 28
  • 32
VestniK
  • 1,910
  • 2
  • 17
  • 29
1

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!

Anglejoy
  • 63
  • 1
  • 8