Results 1 to 5 of 5

Thread: Qtableview Vertical header order

  1. #1
    Join Date
    Jan 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Qtableview Vertical header order

    In the image is possible see that the vertical header has a wrong order, this is due to the sort command, that order the rows . How can i have a vertical header ordered correctly? thanks
    Attached Images Attached Images

  2. #2
    Join Date
    Apr 2009
    Posts
    36
    Thanks
    1
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtableview Vertical header order

    The vertical header is not being sorted, the data in your model is (and by the looks of it, it's possibly sorting on the Diff Tick column). The vertical header is probably being supplied by your headerData method or possibly by just having the vertical header visible. The only work around I can think of if you really want to go back to the vertical header being "sorted" is to add a column that mirrors the vertical header and sort on that column. Otherwise, you may have to instantiate some painful workarounds to get it the way you want.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qtableview Vertical header order

    You could try creating a QHeaderView that ignores the model's header data and uses the visual section number for the label.

  4. #4
    Join Date
    Jan 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qtableview Vertical header order

    Could you explain me how? in my table data are deleted and appended automatically, and every second is done a manual sort of the rows. I'm trying to write an headerData() that return the correct number, but it doesn't work

  5. #5
    Join Date
    Apr 2009
    Posts
    36
    Thanks
    1
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtableview Vertical header order

    If you really wanted the numbers for the vertical column to be correct that are set using the headerData() function, the only thing I can think of is to sort your data manually as you receive it and bypass the view sorting, and then return the correct row number as usual.

    Let me put this another way: Right now what is probably happening (without being able to see your code) is that you are setting the data in the model, adding new data to the end, and setting the row number in headerData() based on the original data. In this scenario, the numbers in the vertical column should be correct since the view is just reflecting the data in your model. However, instead of showing the original data, you are now enabling sorting on the model through either a proxy or the view itself. What happens in this case is now the vertical header numbers are still attached to the data in that row, so when the rows are sorted, the vertical header numbers are now non-sequential. If you're using a proxy model in this case, then maybe you can write your own headerData function that overrides the model's headerData, but this can be a little tricky.

    In my opinion, if this really matters to you, then I would manually sort your own data in the model and turn off sorting in the view. That way, your data is sorted and the vertical header numbers are sequential.

Similar Threads

  1. Replies: 3
    Last Post: 20th January 2011, 13:24
  2. How to change the order of QTableView Column ?
    By Kode.Cooper in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2010, 08:55
  3. No Sort Vertical Header
    By wirasto in forum Qt Programming
    Replies: 4
    Last Post: 1st July 2009, 10:54
  4. Replies: 3
    Last Post: 1st February 2008, 18:18
  5. Showing Icon in vertical header of a table
    By vishal.chauhan in forum Qt Programming
    Replies: 7
    Last Post: 15th January 2007, 10:44

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.