PDA

View Full Version : qAbstractItemView, QAbstractItemModel...



jano_alex_es
15th May 2009, 13:13
Hi,

I have an array, with strings, and I'd like to create a QTableView with all that data.

The problem cames when I start to dive inside the documentation... I need to call SetModel(), then I need to create a QAbstractItemModel, ok; but then I'll surely need QModelIndex... and now I don't know how continue.

But, anyway, seems too complicated, there must be easier ways to do it. I just want to fill a table with strings...

I'd like to use QTableWidget, way easier with all this stuff. but the user can click and edit the info and I can't allow that. Trying to find a method or something to set "clickable" to false but it doesn't seem to exist. :S

How I can do it?

thanks...

spirit
15th May 2009, 13:15
use QTableWidget. take a look at QTableWidgetItem::setFlags and Qt::ItemIsEditable flag.
and also take a look at QAbstractItemView::NoEditTriggers.

jano_alex_es
18th May 2009, 09:22
thanks! that was exactly what I was looking for :)

with


newItem->setFlags(Qt::ItemIsSelectable);

and


void CAddGroup::on_my_table_widget_cellClicked(int iRow,int iColumns)
{
ui.my_table_widget->selectRow(iRow);
}


I have exactly what I needed (didn't select anything when clicking the item after setting up the flag, so I had to do it manually) :)