Results 1 to 2 of 2

Thread: Can't change itemview's headerdata if rootindex is different

  1. #1
    Join Date
    Sep 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Can't change itemview's headerdata if rootindex is different

    Hi,

    I use a QTableView connected to a QStandardItemModel. The view's
    headers start counting at one, but I need them to start counting at
    zero, so I changed them manually (with setHeaderData function, worked
    like a charm).

    But when I change my rootIndex, it gets messed up. Here's an example
    to explain my problem:
    I've got one single valid item in the model's table (at 0,0 ofcourse).
    Now I change my rootIndex to this index, such that the sub-table
    located in the first element of the superior table is the one
    displayed in the itemview. I add some rows and columns to the
    sub-table, everything seems ok. But when I call setHeaderData, there
    is a check in QStandardItemModel::setHeaderData if the header section
    number I want to change is valid. It checks if the the given integer
    value is smaller than rowCount() (respective columnCount()). In my
    opinion, this should be rowCount(rootIndex)... than I would be able to
    edit it again.

    Is this a known bug, or working as intended, or did I miss something?
    I'm using Qt 4.3.x (x=3 or x=4, don't know exactly, I'm not at my work
    PC at the moment).

    Thanks,
    Bag

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can't change itemview's headerdata if rootindex is different

    It might be intended to be that way. The headers for a model are not dependent on the root index. Of course I'm not saying I agree it should be that way In general you can override this by wrapping the model into a proxy model where you will change the headers as you want.

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.