QListWidget. How to set column count.

  • I want to my QListWidget have more than one column and it's item can hold a number of data in that columns(like in table). How can I do that ?

  • I need list. In tree widget I can add some columns, is there any way to add suck columns in QListWidget ?

  • No, because QListWidget is a single dimension widget.

    If you need multiple columns you will have to use, as already suggested, QTableWidget.

  • In my opinion the QTreeWidget is a better choice to display a multi-column list.
    Just set the root decoration to false and add your Items only as top-level items...

  • QTableWidget (well, QTableView) is much more efficient in item layout than QTreeWidget (QTreeView), because that layout is much easier. A table can be made to look just like QTreeWidget does, so I don't see the point of using QTreeWidget instead.

  • Because a QTreeWidget behaves more like a List than QTableWidget. For example you do not have to care about hiding the gridlines (which you normally do not want to see in a list). Also in a tree you have one Item per Row, in a QTableWidget there's one Item per Cell... but in a usual list, you work row-based.
    As you said, a table can of course be configured to look like a list, but a tree can be configured to look like a list with less coding and behaves more like it is expected (at least by me) from a list...

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.