PDA

View Full Version : tableView Problem



hrcariaga
6th February 2008, 01:22
Is there anybody here can help me view my records in MySQL to the tableView?

thanks....

hrcariaga
6th February 2008, 01:42
Please help....

I'm new to Qt and I don't know much of the functions yet..

Heres my problem, I trying to view my records from MySQL to the tableView, but I haven't find a right code.

Please give me a simple code to this.


thanks...:confused:

miguel_mark
6th February 2008, 02:21
use this...



model = new QSqlTableModel(this);
model->setTable(trainingname);//trainingname-name of table to be viewed
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select();

model->setHeaderData(0, Qt::Horizontal, tr("CERTIFICATES"));
model->setHeaderData(1, Qt::Horizontal, tr("CERTIFICATE NO."));
model->setHeaderData(2, Qt::Horizontal, tr("TRAINING CENTER"));
model->setHeaderData(3, Qt::Horizontal, tr("DATE"));
model->sort(0, Qt::AscendingOrder);
view = new QTableView;
view->setModel(model);

hrcariaga
6th February 2008, 03:23
thanks, i finally made it...:D

hrcariaga
7th February 2008, 00:46
I have added a tableView widget in my interface using the designer.

The problem is, I can't find a right code to view my records in it. I'm using MySQL database. Please help...

tnx...

jpn
7th February 2008, 08:29
What did you try so far? I thought you already made it.