PDA

View Full Version : QModelIndex.column() error in QColumnView?



tlustoch
6th December 2008, 16:17
Hello.
I have pretty simple QColumnView and I have assigned to it simple model:


QColumnView *columnView = new QColumnView(this);

QStandardItemModel *model;
QStandardItem *parentItem = model->invisibleRootItem();
for (int i = 0; i < 4; ++i) {
QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
parentItem->appendRow(item);
parentItem = item;
}

columnView->setModel(model);


But now when I for example use signal QColumnView::activated(const QModelIndex &index), the index.row() and index.column() is always 0, no matter on what item I click. And it's same also for other signals/functions. Is it a bug or am I doing something wrong? I just need to know, what item in QColumnView was activated.

Thank for help,
tlustoch

jpn
28th December 2008, 20:45
Hmm, it is row 0 and column 0. Your model doesn't even have multiple columsn. The signal is exactly the same if you'd put the model to a QTreeView. Probably you need to check the parent to find out where the activated index is located.