PDA

View Full Version : Problem with index in a QTreeView



hubert_p
19th October 2006, 12:29
Hi,

I have a prome in ma QTreeView, when I get the index (obtening from the cursor position) that work, but not for the last row.
I use indexAt(QPoint) and I see that the given index does'nt start at 0 but 1. So, is it a proplem of my Qt4 snapshot version, or is it a Qt problem.

Tanks in advance for your response

Philippe

wysota
19th October 2006, 13:34
Could you provide a minimal compilable example which reproduces the problem?

hubert_p
19th October 2006, 15:03
So, I will try to do that in an other example, the orignal code is to big

hubert_p
19th October 2006, 17:04
Attached to that post, I give an example where it is possible to show my problem (displayed with qDebug), if you are going on the last row, you cans see that the index value is -1 -1

And this is the .pro file
TEMPLATE = app
TARGET = qtreeExemple
DEPENDPATH += .
INCLUDEPATH += .

CONFIG += qt

# Input
HEADERS += model.h
SOURCES += main.cpp model.cpp


Thanks for help

Philippe

jpn
22nd October 2006, 16:54
Try mapping the coordinate from the viewport's point of view:

QModelIndex l_currentIndex = indexAt(viewport()->mapFromGlobal(m_currentPos));