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

Store extra information in QListWidget



  • Hi,
    I need to create a list of time periods (after clicking over any of the periods the string becomes a qlineedit that allows you to modify the value)
    Right now I'm using a QListWidget with a delegate that allows me to do this.
    Then, when I need to get back the values of the list, I transform the text to the proper format to load in the qlineedit or whereever I need them.

    The problem is that now, I need to store the seconds while not displaying them in the list.
    Is there any way of doing it? Should I change the QListWidget to a QListView and create a model asociated to it?

    Thanks in advance and feel free to tell me if I haven't been specific enought.


  • Lifetime Qt Champion

    Hi,

    Just store the full time in your model and use a QStyledItemDelegate to change the visualization part. It should be enough to just reimplement displayText.

    Hope it helps


Log in to reply