Results 1 to 2 of 2

Thread: QTreeView: emit dataChange when columns are rearranged

  1. #1
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTreeView: emit dataChange when columns are rearranged

    I did not know about it until recently: QTreeView allows user to manually rearrange columns by dragging them around. So if I have treeview with three columns:
    A B C
    user can rearrange them to be, say
    C A B

    I found out that Qt correctly requests the data in this case, i.e first it requests data for column 0 in the "original" view and it changes to requesting data for column "2" in "rearranged" view

    So far so good. What I don't understand is how I should manually call "dataChange" signal. I mean, when data that I display in column "A" is changed programmatically I am emitting "dataChange" signal with QModelIndex pointing to column 0 (zero), which is "A" in "orignal" view. Should I track rearrangment of the columns and switch to dataChange with QModelIndex pointing to column 1 ("A" in rearranged view) or keep doing what I do regardless of how user moves columns around?

    Thanks.

  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: QTreeView: emit dataChange when columns are rearranged

    Column arrangement (or actually mapping) is only done by and in the view. You don't need to change the model in any way to support it. The view always asks the model based on the "logical" order of columns even if physical order is different.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. datachange
    By giugio in forum Newbie
    Replies: 3
    Last Post: 15th November 2012, 06:06
  2. Replies: 3
    Last Post: 6th October 2010, 08:33
  3. AutoAdjust columns in a QTreeView
    By alexandernst in forum Newbie
    Replies: 4
    Last Post: 27th July 2009, 10:51
  4. Emit clicked( QModelIndex &) from a QTreeView?
    By Ran in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2008, 04:42
  5. Moving columns/hiding columns in QTreeView
    By yogeshm02 in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2007, 16:22

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.