how can i add more column in QListWidget ListMode?



  • how can i add more column in QListWidget ListMode?
    i want to add more info more than the file name
    thank you


  • Moderators

    @opengpu2 You can't. QListWidget is a single dimension widget as the lists itself are.
    Use QTableWidget or QTreeWidget to have more that one column.



  • thank you, iknow QTable can do this.
    but i want to switch between the IconMode and the ListMode, while the data set actually should be view as QListWidget.
    the column after the 1st one is just the custom data of the 1st one, eg. 1st one is fileName, after that i can show it's created time, file type, etc.
    thank you


  • Moderators

    @opengpu2 AFAIK Using QListWidget that cannot be done. It has only one column.



  • i want to use QListWidget because i want to preview in IconMode. Meanwhile, i want to dynamically preview in ListMode but with multi-column(confilicts here, because the QListWidget only support 1 column).

    1 solution is when IconMode i use QListWidget, when "ListMode" i use QTree/QTableWidget, but this is very ugly...and not elegant at all...

    can i preview as IconMode in QTree/QTableWidget ?


  • Moderators

    @opengpu2 In QTreeWidget or QTableWidget you can add your own widgets. For eg. to simulate IconMode you can create a widget consisting of QLabels for text and icon OR use QToolButton with toolButtonStyle as ToolButtonTextUnderIcon and then add this widget to QTreeWidget using setItemWidget OR setCellWidget for QTableWidget.


Log in to reply
 

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