Results 1 to 5 of 5

Thread: updating treeview from tableview

  1. #1
    Join Date
    Nov 2008
    Posts
    23
    Thanks
    2

    Default updating treeview from tableview

    Hello, i am currently using qt4 to program with libpcap and i have created a table view to list all the packets coming through the network interface. Each row consists of one packet and has several columns, source IP, destination IP, Date etc.

    The signal for the tableview is coming from the thread and the main gui is updating the table, but i would like to create a tree view under the table to list extra information from each row in the table.

    i.e by clicking on a row in table view the tree view will show items such as MAC addresses, Port numbers etc

    I am really stuck on this at the moment, i have created the table view and tree view using QStandardItemModel. Do i need to store all that information somewhere and then call it when an item in a row is clicked on?

    Any help would be appreciated

  2. #2
    Join Date
    Nov 2008
    Posts
    23
    Thanks
    2

    Default Re: updating treeview from tableview

    please anyone?

  3. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: updating treeview from tableview

    basically you have two possibilities:
    i) connect to the currentChanged signal (of your table view) and populate the tree view with the data for the selected row in the table
    ii) *if* you have (and you don't iiuyc) all the relevant data in a model M:
    you can set M as the model for both views; show the relevant columns in the table view, and the details (further columns) in the tree view;
    You still need to keep selections in sync: either by connecting to the selectionChanged signal (see QAbstractItemView::selectionModel()), or by simply settings the selectionModel of the treeview to that of the table view. (You would need to get rid of QStandardItemModel, I guess.)
    (Ok, I cheated: this approach would give you one row in the tree. You would want to "transpose" the model... one way would be a proxy model...)

    i) is simpler, so if you just want to display and not edit stuff, you can go that way.

    HTH

  4. #4
    Join Date
    Nov 2008
    Posts
    23
    Thanks
    2

    Default Re: updating treeview from tableview

    step 1 does seem to be the right answer for me but the problem is that the function being called is continuously running in a loop.

    this is what im calling from my thread class

    emit addToTable(header,pkt_data);

    pkt_data being the actual packet data. Now i need this parameter in order to call anything else that i need to add in the tree view. So far this function is only adding to the table view.

    How would be able to add items to the tree view using pkt_data?

  5. #5
    Join Date
    Nov 2008
    Posts
    23
    Thanks
    2

    Default Re: updating treeview from tableview

    any ideas?

Similar Threads

  1. Treeview scrollbar not updating when inserting rows
    By Khal Drogo in forum Qt Programming
    Replies: 11
    Last Post: 29th November 2007, 13:13
  2. Replies: 15
    Last Post: 8th May 2007, 11:46
  3. TreeView, TableView
    By rbrand in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2006, 08:54

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.