Results 1 to 2 of 2

Thread: In Qt4/MVC,how to obtain the content of the selected item?

  1. #1
    Join Date
    Mar 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default In Qt4/MVC,how to obtain the content of the selected item?

    Hello, I wish to put my own data to the current selected item.How do I do this?
    I simply know calling QModelIndex currentIndex() to get the data index of all the current selected items in the QTreeView.
    But how to get the item so that I may change its content?

  2. #2
    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: In Qt4/MVC,how to obtain the content of the selected item?

    Qt Code:
    1. QModelIndex idx = tree->currentIndex();
    2. tree->model()->setData(idx, QVariant("blaa"));
    To copy to clipboard, switch view to plain text mode 

    See QAbstractItemModel::setData() for reference.

Similar Threads

  1. Changing selected item color in non-current window.
    By Doug Broadwell in forum Qt Programming
    Replies: 1
    Last Post: 26th August 2007, 07:09
  2. QTreeView: selection behavior upon selected item removal
    By Pieter from Belgium in forum Qt Programming
    Replies: 6
    Last Post: 11th July 2007, 16:00

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.