View Full Version : The tables in the qt creator

22nd September 2010, 00:17

I want to create a table by using a qtableView or qtableWidget.

But how do I put the Header?
And how to enter data for the table?

Thank you

22nd September 2010, 21:13
I found this example ===>> http://doc.qt.nokia.com/latest/demos-books.html

But this exam as a Sql.

// Create the data model
model = new QSqlRelationalTableModel(ui.bookTable);

// Set the localized header captions
model->setHeaderData(authorIdx, Qt::Horizontal, tr("Author Name"));
model->setHeaderData(genreIdx, Qt::Horizontal, tr("Genre"));
model->setHeaderData(model->fieldIndex("title"), Qt::Horizontal, tr("Title"));
model->setHeaderData(model->fieldIndex("year"), Qt::Horizontal, tr("Year"));
model->setHeaderData(model->fieldIndex("rating"), Qt::Horizontal, tr("Rating"));

What is the solution??!!
How do I put the Header ?? And how to enter data for the table ??

22nd September 2010, 22:46
No Answers

22nd September 2010, 23:29
There is extensive documentation on Qt's model/view approach to table presentation in the class documentation and in the tutorial and demo programs. Read those before asking such a general question.

And stop bumping your own posts. Readers are perfectly able to see them all by themselves. You reduce your chances of an answer if you keep shoving them in someone's face.

22nd September 2010, 23:46
Start with Model/View Programming (http://doc.qt.nokia.com/4.6/model-view-programming.html). All your answers are there. The Chart Example is very informative.