QTableWidget delegate



  • Hi!

    I have a dynamically changing QTableWidget (rows are not the same). Some of the rows have top border. I use delegate for it, but if I delete the rows and re-add them, the delegate doesn't disappear from the row. How can I fix this?

    Thanks!


  • Moderators

    Delegates are a view related concept. They are attached to row/column number, not to particular model or changes in it.
    For example if there's a delegate set for row 2 and you remove row 2 the delegate is not removed for that row. Instead the previous row 3 becomes row 2 and the same delegate is used for it.

    If you set a delegate using setItemDelegateForRow() and don't want it anymore when row is removed you need to clear it (by setting to nullptr).
    Note that the view does not take ownership of the delegate so you need to explicitly delete it if you don't use it anymore.


Log in to reply
 

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