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. QTreeWidget.itemAt returns wrong item in dropEvent

QTreeWidget.itemAt returns wrong item in dropEvent

Scheduled Pinned Locked Moved Solved General and Desktop
pysidedropeventqtreewidget
3 Posts 2 Posters 276 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.
  • F Offline
    F Offline
    ForeverNoob
    wrote on 15 Oct 2024, 10:41 last edited by
    #1

    Hello,

    Code in QTreeWidget dropEvent:

    targetItem = self.targetTree.itemAt(event.position().x(), event.position().y())
    

    the item returned is consistently 4 rows under the correct one. Why is that?

    TIA

    P 1 Reply Last reply 15 Oct 2024, 13:37
    0
    • F ForeverNoob
      15 Oct 2024, 10:41

      Hello,

      Code in QTreeWidget dropEvent:

      targetItem = self.targetTree.itemAt(event.position().x(), event.position().y())
      

      the item returned is consistently 4 rows under the correct one. Why is that?

      TIA

      P Offline
      P Offline
      Pl45m4
      wrote on 15 Oct 2024, 13:37 last edited by Pl45m4
      #2

      @ForeverNoob said in QTreeWidget.itemAt returns wrong item in dropEvent:

      Why is that?

      It can only be for one reason:

      event.position().x(), event.position().y()
      

      these coords are not what you would expect.

      The documentation says:

      item at the coordinates (x, y). The coordinates are relative to the tree widget's viewport().

      So compare that with the position of your correct item


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      F 1 Reply Last reply 16 Oct 2024, 11:32
      3
      • P Pl45m4
        15 Oct 2024, 13:37

        @ForeverNoob said in QTreeWidget.itemAt returns wrong item in dropEvent:

        Why is that?

        It can only be for one reason:

        event.position().x(), event.position().y()
        

        these coords are not what you would expect.

        The documentation says:

        item at the coordinates (x, y). The coordinates are relative to the tree widget's viewport().

        So compare that with the position of your correct item

        F Offline
        F Offline
        ForeverNoob
        wrote on 16 Oct 2024, 11:32 last edited by
        #3

        @Pl45m4 Sorry, I was working with the wrong dropEvent. Me stupid. Things work now.

        Thanks

        1 Reply Last reply
        0
        • F ForeverNoob has marked this topic as solved on 16 Oct 2024, 11:33

        1/3

        15 Oct 2024, 10:41

        • Login

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