Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Issue with custom delegate in tableview

    General and Desktop
    2
    5
    1216
    Loading More Posts
    • 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
      alizadeh91 last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • A
          alizadeh91 last edited by

          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 Reply Quote 0
          • A
            alizadeh91 last edited by

            Does anyone knows how to deal with it?!

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              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 Reply Quote 0
              • First post
                Last post