1
votes

I have these messages received on the can bus which need to be displayed on a suitable Qt Widget (Please refer attached picture). It seems I can use QTreeView for it.

I need to show a tree which contains many messages as shown in attached picture. Each row will contain information about the received message.

It should consist of columns :

  • Length
  • Time of receiving
  • Message ID
  • Name of the message
  • Message content

and when I expand message it should its different signals.

enter image description here

How can I make a QTreeView with columns ?

1
All you need is a model that has more than one column. What have you tried exactly? What's not working?Mat

1 Answers

2
votes

There is a problem that won't allow you to make what that screenshot shows, and it is that first and second level tiers don't have the same columns layout. AFAIK, it's not possible to do that with QTableView or QTableWidget current implementations and you will have to implement your own class.

If you can adapt to having the same column layout for both levels, then keep reading what I wrote before taking another sight to your screenshot:

You can, QTreeView is only a QTableView with some art for first column.

Add all the columns you want to your model. A simple [QStandardItemModel][1] would suffice to do something like the screenshow

Just remember 2 things:

  1. Only first column item childs will be displayed.
  2. First column cannot be hidden.

    [1]: http://qt-project.org/doc/qt-4.8/qstandarditemmodel.html