PDA

View Full Version : In Qt4/MVC,how to obtain the content of the selected item?



qintm
23rd March 2006, 04:52
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?

jpn
23rd March 2006, 06:37
QModelIndex idx = tree->currentIndex();
tree->model()->setData(idx, QVariant("blaa"));

See QAbstractItemModel::setData() (http://doc.trolltech.com/4.1/qabstractitemmodel.html#setData) for reference.