Results 1 to 2 of 2

Thread: [4.6] QTreeView Clicked() signal returns column specific data

  1. #1
    Join Date
    Dec 2009
    Posts
    41
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default [4.6] QTreeView Clicked() signal returns column specific data

    Hi all!

    I am using a QTreeView whith 5 columns. The first one, labelled id contains a number. This number is used to retrieve information in an database. So I use the clicked signal : when I click on a line on the qtreeview, I can access the data I have clicked on (index.data(0)). But this behaviour forces me to click on the id column to get the information related to this line. Indeed, if I click any other column, a unrelevant qstring is catched and I can't use it to retrieve info in the db.

    What I would like is that whatever the column I click on, it returns me the value stored in the first column.

    I have seen row function but it is not suitable here as I use a QSortFilterProxyModule so if I filter the model, the row column isn't the right value.


    Thanks
    Last edited by Guilo; 22nd January 2010 at 23:14.

  2. #2
    Join Date
    Nov 2009
    Posts
    129
    Thanks
    4
    Thanked 29 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [4.6] QTreeView Clicked() signal returns column specific data

    Quote Originally Posted by Guilo View Post
    I have seen row function but it is not suitable here as I use a QSortFilterProxyModule so if I filter the model, the row column isn't the right value.
    Unless you’re either filtering out the first column, putting it in an unpredictable column, or putting columns from different source rows into one target row, index.sibling(index.row(), 0).data() should still work.

    If that really can’t work because of the filtering, then perhaps you could use QSortFilterProxyModel::mapToSource to get the source model index, then retrieve what you need directly from its appropriate sibling in the unfiltered model.

Similar Threads

  1. How to get all column data on row clicked
    By wirasto in forum Qt Programming
    Replies: 7
    Last Post: 9th November 2009, 06:21
  2. signal mapping on pushbutton signal clicked
    By wagmare in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 08:54
  3. Strange error: doc.setContent(data) returns false
    By jiveaxe in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2009, 02:38
  4. Emit clicked( QModelIndex &) from a QTreeView?
    By Ran in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2008, 05:42
  5. How to find which column clicked from a treeview.
    By mekos in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2008, 17: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.