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. [Solved] Check click outside QGraphicsItem parent and child
Qt 6.11 is out! See what's new in the release blog

[Solved] Check click outside QGraphicsItem parent and child

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.6k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi all

    I need to have one main QGraphicsItem always showed and another children QGraphicsItem showed for particular event. I want this secondary child QGraphicsItem to hide automatically if user click in the scene out from the secondary child QGraphicsItem and out from the parent main QGraphicsItem (basically out of both). Currently I'm trying to hide the secondary child item based to the focusout event but doesn't work since this event is generated also if I click over the parent item always visible. Currently I'm still not able to found a solution...

    Someone have a suggestion regarding how to fix this problem?

    Thank you

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

      Hi,

      Just a quick idea but what about using installSceneEventFilter and check there where you cursor can be found when the focusOut event occurs ?

      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
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Hi

        Thank you for your reply. Indeed I already tried the installSceneEventFilter way but the problem is not easy to know the next will have focus. Basically the sequence is to send the focusout event to the item will going to loose the focus and then set the focus to the next item will going to get. This mean when the item will receive the focus out event is not possible to knwo who will be the next since not yes "assigned". This, obviously, at item level, scene or view have the focus event passing the two items who will loose and get the focus...

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Hi again

          Just found a solution based to what I wrote before :). Simply I connect to the focusItemChanged scene signal from inside my child item. Using this way I can know who will receive new item. If is different from child a parent item I'll close the chils and disconnect from signal. Easy and working.

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

            Nice !

            Thanks for sharing your solution :)

            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