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

How to add multiple values inside a single cell of pyside2 QTableWidget?



  • I am working on a GUI using pyside2, where I have multiple values for columns of a single record. The soultion I have thought for this is that I will show data in QTableWidget and inside table widget show multiple values inside a single cell. Does anyone has any idea how to add multiple values inside a single cell of QTableWidget.
    Thanks



  • @haider
    You have to start by thinking out what display/interface/editability you want for these. For example, a comma-separated string list? Separate items on lines of their own? A combo box? A complete sub-table?



  • @JonB it can be a separate items on lines of their own or a complete sub table. Any solution would be helpful for me


  • Banned

    JonB to put more than one value within a single cell you pretty much have to combine them within code prior to putting them into that cell -- basically treat each cell as if it were like a QLineEdit without all the bells/whistles that come with a QLineEdit object

    My other question would be why are even wanting to do this as it seems like that would be rather confusing to the User and be a semi-nightmare when it came to editing -- why not just add more columns? If its a header issue then there are ways to get a header to span more than one column.

    As for how to manipulate this data you might want to look into the Data Model aspect of PyQt



  • @Denni-0 said in How to add multiple values inside a single cell of pyside2 QTableWidget?:

    JonB to put more than one value within a single cell you pretty much have to combine them within code prior to putting them into that cell -- basically treat each cell as if it were like a QLineEdit without all the bells/whistles that come with a QLineEdit object

    My other question would be why are even wanting to do this as it seems like that would be rather confusing to the User and be a semi-nightmare when it came to editing -- why not just add more columns? If its a header issue then there are ways to get a header to span more than one column.

    As for how to manipulate this data you might want to look into the Data Model aspect of PyQt

    @Denni-0 if we can span header to more then one columns then can you help me how we can do that with pyside2


  • Banned

    Really you cannot do a simple google search such as "pyqt QTableWidget header span columns"

    Where upon I got the following as my first result of the above Google search
    PyQT - Group cells in QTableWidget - Stack Overflow

    And looking at that it appears to answer this very question

    At least do a little leg work before coming back to ask for more help -- if your not willing to put effort into to it do not expect others to for you


Log in to reply