0

This question is more about the Qt framework knowledge than coding problem.

I am wondering if there exists in the Qt Framework a container which displays a list view of expandable/collapsable items. The items are much more complex than simple QLabels.

To be more precise, I need a list of custom widgets.
Each widget has a QHBoxLayout (to make each item fit in a "line") which contains inner widgets including an expanding/collapsing toggle button (at the first/left position of the layout).
When the expanding/collapsing button is switched on, I want to see a container panel appear below and showing more detailed information (another complex widget).
Obviously, when the expanding/collapsing button is switched off, this additional panel must hide.

My question is, does such a gui design structure exist in the Qt framework or not ?
I could not find such an object in the Qt documentation but I may have miss it since I don't really know by what name it could be called.

I could probably do this with more or less tricky workarounds as shown here for example.
But I want to be sure that I will not implement a class that may already exist in the Qt framework since this kind of container are quite common in many applications.

I would be very grateful if someone knowledgeable about the Qt framework could enlighten me about it.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Fareanor
  • 5,900
  • 2
  • 11
  • 37
  • No, there is not. I recommend you check the available widgets https://doc.qt.io/qt-5/qtwidgets-module.html – eyllanesc Jun 07 '19 at 08:42
  • 1
    Short answer: No. – user6556709 Jun 07 '19 at 08:42
  • @eyllanesc Yes I already checked it but as I don't know the name of what I'm looking for, I may have miss the widget if it exists. But thanks for your answer. – Fareanor Jun 07 '19 at 08:50
  • @Fareanor I do not say that you look for the name if you do not read the description of each class, Qt has worked hard to make a clear and precise documentation. :-) – eyllanesc Jun 07 '19 at 08:51
  • @eyllanesc I know but reading the whole documentation for all widgets is too much. That's why I filter the names that most probably could correspond. So if this structure does not exists, it explains why I could not find it :) (And yes, I agree, the Qt documentation is very precise and helpful). – Fareanor Jun 07 '19 at 08:53
  • @Fareanor Maybe for this particular case it does not help you or maybe you do not have time but in the long term it is necessary if you want to continue using Qt, the more you know each class (not only the widget but the other submodules) your code will be better. – eyllanesc Jun 07 '19 at 08:55
  • @eyllanesc You are completely right. – Fareanor Jun 07 '19 at 08:57

1 Answers1

0

To summarize, the question here was divided in two parts:

  • About the existence of an expandable widget.
  • About the existence of a list view which can handle any widgets including expandable ones.

As such containers do not exist in the Qt framework, I have written my own implementation of these which can be found here.
In qt_widgets_extensions.hpp, I defined qt_ext::QExpandableWidget and qt_ext::QListWidgetView which completely answer both aspects of the question. You can check the link for more details about the features provided by these containers.

I think it could be easy to translate this implementation into another language like Python for example.

Fareanor
  • 5,900
  • 2
  • 11
  • 37