Results 1 to 8 of 8

Thread: How can I get data from the hidden column in a QTreeView?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2015
    Posts
    6
    Thanks
    1
    Qt products
    PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I get data from the hidden column in a QTreeView?

    I am creating QStandardItem and recursively appending rows..

    child_node = QtGui.QStandardItem("ITEM TEXT")
    root.appendRow(child_node)

    "ITEM TEXT" - is getting directly from sqlite...for each iteration...

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,323
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How can I get data from the hidden column in a QTreeView?

    Well then it is easy - when you create the QStandardItem, just call
    Qt Code:
    1. child_node.setData( QVariant( ID ), Qt::UserRole )
    To copy to clipboard, switch view to plain text mode 
    When you get the selected item, then it is just
    Qt Code:
    1. ID = selected_node.data( Qt::UserRole )
    To copy to clipboard, switch view to plain text mode 
    (or whatever the appropriate syntax is - I'm not a python programmer).

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

    serj (4th April 2015)

  4. #3
    Join Date
    Apr 2015
    Posts
    6
    Thanks
    1
    Qt products
    PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I get data from the hidden column in a QTreeView?

    It works! Thanks! This is exactly what I need..

    child_node.setData(QtCore.QVariant(str(chld["ID"]))) #setting data

    selected_id = str(index.model().itemFromIndex(index).data().toSt ring()) #getting data

Similar Threads

  1. Replies: 4
    Last Post: 27th February 2014, 09:42
  2. Showing a Hidden QTableView Column
    By dchow in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2011, 00:11
  3. Replies: 1
    Last Post: 23rd January 2010, 22:04
  4. Replies: 2
    Last Post: 21st October 2009, 08:13
  5. hidden QListView column suddenly visible
    By edb in forum Qt Programming
    Replies: 10
    Last Post: 27th January 2006, 08:00

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
  •  
Qt is a trademark of The Qt Company.