Results 1 to 3 of 3

Thread: getting Itemtext

  1. #1
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default getting Itemtext

    Hello friends,

    how can I get the itemtext from my Teeview??

    I´am searching now about 1 hour. Have any an idea???

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: getting Itemtext

    You can use QAbstractItemModel::data with the QAbstractItemView::currentIndex model index and a display role to get the text of the current item.

    Qt Code:
    1. QString txt;
    2. if(tree->currentIndex().isValid())
    3. {
    4. txt = tree->model()->data(tree->currentIndex(), Qt::DisplayRole).toString();
    5. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: getting Itemtext

    Thank you!!! It rocks!

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.