qAbstractItemView, QAbstractItemModel...
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...
Re: qAbstractItemView, QAbstractItemModel...
use QTableWidget. take a look at QTableWidgetItem::setFlags and Qt::ItemIsEditable flag.
and also take a look at QAbstractItemView::NoEditTriggers.
Re: qAbstractItemView, QAbstractItemModel...
thanks! that was exactly what I was looking for :)
with
Code:
newItem->setFlags(Qt::ItemIsSelectable);
and
Code:
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) :)