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. TableWidget defocus problem
Forum Updated to NodeBB v4.3 + New Features

TableWidget defocus problem

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 575 Views 1 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.
  • B Offline
    B Offline
    BrianE
    wrote on last edited by
    #1

    When clicking on a TableWidget cell or heading, one or more cells get highlighted. After (or pehaps before) I process the event I'd like to programatically turn off that highlighting without having to click elsewhere. I haven't spotted a way to do that yet but I'm new to Qt.

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

      QTableWidget inherith QAbstarctItemView, which has a clearSelection() method. Just call it in a slot connected to the clicked() signal.

      But if you really don't want items to be selected a better way would be to not make them selectable in the first place. When adding QTableWidgetItems call setFlags() on them and don't set the Qt::ItemIsSelectable flag.
      You can also setSelectionMode() to QAbstractItemView::NoSelection.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BrianE
        wrote on last edited by
        #3

        Thank you for a comprehensive answer - so simple when you know how! clearSelection() solved the problem sufficiently but your answer enabled me to read through QAbstarctItemView without tears and I was able to investigate the various flags etc. The more I play with Qt the more I love it.

        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