Results 1 to 2 of 2

Thread: How to catch QTreeView column moved by user?

  1. #1
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    7
    Thanked 5 Times in 4 Posts

    Question How to catch QTreeView column moved by user?

    Hi,

    I have searched and searched but can't find an answer to this.

    I am using a plain QTreeView ontop of a QSqlTableModel to display the contents of an SQLlite table. It's working just fine.

    I want to keep a track of the headings in the TableView so I can restore their state when the program is relaunched, and have happily hidden/shown/moved columns programmatically.

    However, I need to be able to trap when a user drags a column heading from one place to another (which is a nice feature of QTreeView). But there appears to be no signals or events that I can trap to spot this.

    I tried subclassing QTreeView and implementing all the protected slots like columnMoved(), removeRows() et al but that didn't do anything (although the removeRows slot did get called from time to time). I tried installing an eventFilter on the QTableView but got very few events that could help (in/out/tooltip request).

    So, how can I trap when a user drags the column heading and moves it in a QTreeView?

    Many thanks in advance,
    Mark

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to catch QTreeView column moved by user?

    You have to combine things: QTreeView::header() -> QHeaderView::sectionMoved().

  3. The following user says thank you to Lykurg for this useful post:

    liversedge (27th July 2010)

Similar Threads

  1. enable user editing of QTreeView headers?
    By iraytrace in forum Newbie
    Replies: 0
    Last Post: 9th October 2009, 22:25
  2. QTreeView - how to force an end to a user edit
    By onamatic in forum Qt Programming
    Replies: 2
    Last Post: 17th November 2008, 21:21
  3. Fixed Column in QTreeview
    By ormonde in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2008, 07:49
  4. No delegate for 1 column in QTreeView
    By mace in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2007, 10:55
  5. Setting one* column of QTreeView to be editable
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 18th October 2006, 20:31

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.