2

I have to display a large amount of text in a python/QT UI. This text represents a pattern sent by a tester (digital signals).

exemple:

// Command 1
0x002045A85
0x002045A84
0x002045A83
...
// Command 2
0x002045A85
0x002045A84
0x002045A83
...

I would display on the UI only the comments included in the pattern. If the user click on a comment line, the text will expand and some hexadecimal codes will be written below the clicked line. If the user click again on the same comment line, the hexadecimal lines will be collapsed.

If the user click on a hexadecimal line, a graphic with the digital signal will be pop-up.

I have no idea how to do this.

Please, someone could send me an example which could help me in this development ?

Benoît

Ben
  • 21
  • 1

1 Answers1

2

Use a QTreeWidget: The "Command N" lines are your first level, which can be unfolded to reveal the hexadecimal number items. QTreeWidget has a clicked() signal which gives you the clicked item, so implementing the click event for showing the signal graphic should be easy.

The only downside of this approach is that QTreeWidget requires you to create the whole tree structure at once. If your data is very large and memory usage becomes a concern, you can later grow this UI into a QTreeView with a custom model that loads the second-level data lazily.

Stefan Majewsky
  • 5,427
  • 2
  • 28
  • 51