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. QTreeView::indexat returning invalid index for part of very lowest items

QTreeView::indexat returning invalid index for part of very lowest items

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.0k 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.
  • M Offline
    M Offline
    Moschops
    wrote on last edited by
    #1

    I've got a QTreeView. For two of the columns, I have code such that the mouse pointer changes to a little hand. Like this:

    @bool AnalysisResultsListDock::eventFilter(QObject* watched, QEvent* event)
    {
    if(event->type() == QEvent::MouseMove)
    {
    auto mouseMoveEvent = dynamic_cast<QMouseEvent*>(event);
    auto position = mouseMoveEvent->globalPos();
    position = ui->treeView->mapFromGlobal(position);
    auto index = ui->treeView->indexAt(position);
    if(index.column() == 1 || index.column() == 2)
    {
    ui->treeView->setCursor(Qt::PointingHandCursor);
    }
    else
    {
    ui->treeView->setCursor(Qt::ArrowCursor);
    }
    }

    return QDockWidget::eventFilter(watched, event);
    

    }@

    However, when I scroll down to the very bottom of the treeview, and mouse over, the pointer does not change until I am about one and a half lines up (i.e. halfway across one item, it changes).

    Adding breakpoints, it seems that the index being returned from indexAt is invalid when the mouseMove Event is over the pixels taken up by roughly one and a half rows at the bottom of the treeview.

    This makes little sense to me. I didn't write the code, but I can read it and I don't see anything obviously wrong; is there some kind of offset value being calculated wrongly or other such?

    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