Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72234

QTreeView's itemAt(pos) does not relate to widget's viewport

    XMLWordPrintable

Details

    • Windows

    Description

      It seems that QTreeWidget's itemAt does not take header into account, hence itemAt(p) p is not relative to widget's viewport. In order for itemAt to return a correct item based on given coordinates, one has to reduce header height from p's Y value, like:

      QPoint fixedPos(helpEvent->pos());
      fixedPos.setY(fixedPos.y() - this->header()->height());
      QTreeWidgetItem* item = this->itemAt(fixedPos);
      

      Please find the attached example which demonstrates this issue. In the example, move mouse cursor on top of one of the items and see what the example prints in the output.

      This seems to be an old issue (reproduced with 5.12, 5.11 and 5.6.3), so changing the behavior might not be well received, but this should at least be mentioned in the documents and possibly show a workaround solution how to make it work

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            pekarjal Pekka Karjalainen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes