PDA

View Full Version : table



gambr
13th November 2006, 11:28
Hi all,
I need to insert a table in a QT GUI. Which is the widget/view object you suggest? I'm working with QT 4.2.

Requirements are basic. Tab button should move from a cell to the following one in the same row, while enter button should move down to the following row or create a new one.

Thanks for your help.
Gianni

jpn
13th November 2006, 11:47
QTableWidget might be a easier to start with but QTableView is more flexible in the long run and is also more popular (http://www.qtcentre.org/forum/f-qt-programming-2/t-dynamic-updates-to-a-table-widget-2511.html) amongst QtCentre users. ;)

munna
13th November 2006, 11:47
You can use either QTableView (http://doc.trolltech.com/4.2/qtableview.html) or QTableWidget (http://doc.trolltech.com/4.2/qtablewidget.html)

gambr
13th November 2006, 12:10
Thanks jpn an munna,
as far as I know QTableWidget is older than QTableView. The second one uses a new way of programming introduced with QT4, is that right?

I will try with the easiest then. I will ask again if I'm in trouble ;)

Gianni

jpn
13th November 2006, 12:21
QTableWidget is actually a subclass of QTableView. QTableWidget is just a "convenience view", with it's prebuilt default model. So with QTableWidget you don't need a separate model and you can work with QTableWidgetItems instead of QModelIndexes.