+ Reply to Thread
Results 1 to 4 of 4

Thread: current index of the sleected item in QTreeWidget

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    630
    Thanks
    106
    Thanked 41 Times in 40 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default current index of the sleected item in QTreeWidget

    hi friends,
    can u please help me how i can get the currentindex value as integer of the selected item in QTreeWidget ...

    i manage to get the data but the currentIndex() at present returning QmodelIndex() . not able to convert it to integer ..


    can any one please help me ...
    "Behind every great fortune lies a crime" - Balzac

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,368
    Thanks
    19
    Thanked 992 Times in 903 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: current index of the sleected item in QTreeWidget

    to what integer? Row or column? E.g.
    Qt Code:
    1. currentIndex().row()
    To copy to clipboard, switch view to plain text mode 
    Artistic Style Plugin (1.3.0) for Qt Creator 3.0.0: http://astyleplugin.sourceforge.net.

  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    630
    Thanks
    106
    Thanked 41 Times in 40 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: current index of the sleected item in QTreeWidget

    thanks for reply ...

    i have attached my QTreeWidgets screenshot with this thread ...

    here if the user selects CIM_ComputerSystems or first child of CIM_System and clicked some pushButton .. how can i identify it in my pushButton slot xx() the item selected ... by its index number or some other way ...

    i tried like this
    cout<<_treeView->currentIndex().row()<<endl;

    it all showing 0 as constant...

    but i am manage to get the string of the QTreeWidget Item..

    please help ...
    Attached Images Attached Images
    "Behind every great fortune lies a crime" - Balzac

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,368
    Thanks
    19
    Thanked 992 Times in 903 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: current index of the sleected item in QTreeWidget

    It is returning always 0 because it is relative to its parent. If you want unique identification you have to set a uuid to the items yourself using the Qt::UserRole role. (Or create a "integer path" back to the root item)
    Artistic Style Plugin (1.3.0) for Qt Creator 3.0.0: http://astyleplugin.sourceforge.net.

  5. The following user says thank you to Lykurg for this useful post:

    wagmare (12th August 2010)

+ Reply to Thread

Similar Threads

  1. Connect button and pass QListView current index
    By been_1990 in forum Qt Programming
    Replies: 3
    Last Post: 30th November 2009, 16:20
  2. get and set current item in QTableView
    By pospiech in forum Newbie
    Replies: 8
    Last Post: 25th May 2009, 13:25
  3. get current item from QCompleter
    By evgenM in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 18:16
  4. QTreeWidget child index
    By merlvingian in forum Newbie
    Replies: 2
    Last Post: 2nd October 2006, 17:42
  5. How to get current row(column) index in the QTextTable?
    By denny.t in forum Qt Programming
    Replies: 3
    Last Post: 5th April 2006, 07:53

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