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. Issue with custom delegate in tableview
QtWS25 Last Chance

Issue with custom delegate in tableview

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.5k Views
  • 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
    alizadeh91
    wrote on last edited by
    #1

    Hi,
    I have issue with Highlighting cell of tableView with my own delegate (checkbox), i used this code :
    @
    if(option.state & QStyle::State_Selected)
    {
    painter->fillRect(option.rect,option.palette.highlight());
    }
    @

    this works but the problem is that when the focus of table is changed the color of selected row have to be gray but in my table the color of my delegate cells will stay dark blue(state_selected).
    How to fix that?
    thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Maybe add a check with QStyle::State_HasFocus ?

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alizadeh91
        wrote on last edited by
        #3

        Yeah that's true, but my problem is that i don't know with which palette i should paint the delegate background when it has not focus?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alizadeh91
          wrote on last edited by
          #4

          Does anyone knows how to deal with it?!

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Isn't this something for the QPalette::Inactive color group ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

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