Results 1 to 2 of 2

Thread: QModelIndex.column() error in QColumnView?

  1. #1
    Join Date
    Dec 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy QModelIndex.column() error in QColumnView?

    Hello.
    I have pretty simple QColumnView and I have assigned to it simple model:

    Qt Code:
    1. QColumnView *columnView = new QColumnView(this);
    2.  
    3. QStandardItem *parentItem = model->invisibleRootItem();
    4. for (int i = 0; i < 4; ++i) {
    5. QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
    6. parentItem->appendRow(item);
    7. parentItem = item;
    8. }
    9.  
    10. columnView->setModel(model);
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by jpn; 28th December 2008 at 20:34. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QModelIndex.column() error in QColumnView?

    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.
    J-P Nurmi

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.