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. How not to show selection when QTreeView has no focus?
Qt 6.11 is out! See what's new in the release blog

How not to show selection when QTreeView has no focus?

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

    For QTreeView,
    when focused, selection shows with blue background,
    when not focused, selection shows with gray background.
    How not to show selection when not focused by settings instead of selecting none when losing focus by codes?

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

      Hi,

      Do you mean clear the selection and reinstate it afterward ?

      The focusInEvent and focusOutEvent are likely what you are looking for.

      Out of curiosity, why do you want that behaviour ? It makes your users lose information about the state of the application.

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

      jronaldJ 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Do you mean clear the selection and reinstate it afterward ?

        The focusInEvent and focusOutEvent are likely what you are looking for.

        Out of curiosity, why do you want that behaviour ? It makes your users lose information about the state of the application.

        jronaldJ Offline
        jronaldJ Offline
        jronald
        wrote on last edited by jronald
        #3

        @SGaist said in How not to show selection when QTreeView has no focus?:

        Do you mean clear the selection and reinstate it afterward ?
        The focusInEvent and focusOutEvent are likely what you are looking for.

        Yes. If there is no flag for this, events must help.

        @SGaist said in How not to show selection when QTreeView has no focus?:

        Out of curiosity, why do you want that behaviour ? It makes your users lose information about the state of the application.

        Because most of the time, it's for view only.
        If any combination of focus policies is possible, it'll be more powerful, user demands in appications can be very special.

        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