Results 1 to 5 of 5

Thread: Problem with index in a QTreeView

  1. #1
    Join Date
    Sep 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Problem with index in a QTreeView

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with index in a QTreeView

    Could you provide a minimal compilable example which reproduces the problem?

  3. #3
    Join Date
    Sep 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with index in a QTreeView

    So, I will try to do that in an other example, the orignal code is to big

  4. #4
    Join Date
    Sep 2006
    Posts
    8
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with index in a QTreeView

    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
    Attached Files Attached Files

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Problem with index in a QTreeView

    Try mapping the coordinate from the viewport's point of view:
    Qt Code:
    1. QModelIndex l_currentIndex = indexAt(viewport()->mapFromGlobal(m_currentPos));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  6. The following user says thank you to jpn for this useful post:

    hubert_p (23rd October 2006)

Similar Threads

  1. QTreeView problem scrolling to end.
    By seneca in forum Qt Programming
    Replies: 7
    Last Post: 22nd December 2015, 12:08
  2. Selection problem in QTreeView
    By Valheru in forum Qt Programming
    Replies: 3
    Last Post: 7th October 2006, 16:02
  3. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 12:48
  4. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.