Results 1 to 4 of 4

Thread: current index of the sleected item in QTreeWidget

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 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,380
    Thanks
    19
    Thanked 1,005 Times in 913 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 

  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 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,380
    Thanks
    19
    Thanked 1,005 Times in 913 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)

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

    wagmare (12th August 2010)

Similar Threads

  1. QTreeWidget child index
    By merlvingian in forum Newbie
    Replies: 3
    Last Post: 9th July 2015, 05:40
  2. Connect button and pass QListView current index
    By been_1990 in forum Qt Programming
    Replies: 3
    Last Post: 30th November 2009, 17:20
  3. get and set current item in QTableView
    By pospiech in forum Newbie
    Replies: 8
    Last Post: 25th May 2009, 14:25
  4. get current item from QCompleter
    By evgenM in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 19:16
  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, 08: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.