Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTableWidget delegate

QTableWidget delegate

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 669 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amezei
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved