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

Unification of QAbstractItemView::visualRect for QLisView

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Widgets: Itemviews
    • None

    Description

      Qt verison 6.4

      QAbstractItemView class has visualRect(const QModelIndex &index) method that "{{returns the rectangle on the viewport occupied by the item at index." }}For QTableView and QTreeView it returns what the description says. But for QListView it returns something similar to sizeHint for the item.

      If a size of the item is bigger than the QListView's viewport by default a horizontal scroll bar is displayed. In this case view's viewport size remains the same, but item's visual rect is bigger. Also if horizontal bar is disabled and item text is elided, the visual rect still returned bigger than the view's viewport.

      I want to create a view that shows tooltip for an item only when it's content didn't fit in the visual rect (i.e. text is elided). Something like in this old guide. I did it by reimplementing QAbstractItemView::viewportEvent. When QEvent::ToolTip is passed I check itemDelegate's sizeHint with visualRect's size to decide whether to show or not to show tooltip. But because of the above described problem I had to hard code for QListView.

       

      Expected result: visualRect method for QListView returns the rectangle on the viewport occupied and it can not be bigger than view' viewport (as it is now).

      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
            olecsa Oleksii Hladyshko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes