Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTableWidget or QTableView - Presenting many info in one table cell



  • I just downloaded a program to download videos and after seeing this table (image below) I got curious on how I would create something similar in Qt.

    Screenshot_2.png

    I have used QTableWidget and I can't think of how to do this using it so I am guessing it's QTableView(haven't yet quite understood the model/view concept) but I took a quick look at its doc but couldn't have a idea on how to do that using it.



  • You need to set a QStyledItemDelegate for the view.
    The delegate will replace the cell in the table showing your custom widget that you can style according to your needs.



  • @gde23 I went and searched for it and from I could understand, I could use a QGridLayout to achieve something similar to the image in the OP, right?



  • @hbatalha
    Depends how "similar" you mean by "similar".

    QStyledItemDelegate is the right way to go.



  • @JonB said in QTableWidget or QTableView - Presenting many info in one table cell:

    Depends how "similar" you mean by "similar".

    Let's say then, visually the same. Using QGridLayout in delegate class I can achieve that?



  • For the layout on the delegate you can use a grid layout or cascaded horizontal/vertical layouts, that really does not matter.
    However, if you are not familiar with basic widget layouts I would suggest starting with something more basic than delegates.
    E.g. you can first setup the model/view, then make a standalone widget to be used as delegate, and finally setup the delegate.


Log in to reply