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

QTreeWidget.itemAt returns wrong item in dropEvent

Scheduled Pinned Locked Moved Solved General and Desktop
pysidedropeventqtreewidget
3 Posts 2 Posters 364 Views 2 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.
  • F Offline
    F Offline
    ForeverNoob
    wrote on 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

    Pl45m4P 1 Reply Last reply
    0
    • F ForeverNoob

      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

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on 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
      3
      • Pl45m4P Pl45m4

        @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 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

        • Login

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