Hi All
On a QWidget I've displayed a QTreeView and QTabWidget. They both have the same QAbstractItemModel as source model and the idea is to view the treestructure in the treeview but let the user modify the individual items in the QTabWidget where the items are also shown. Basically exactly the same as in C++ GUI Programming with Qt 4, the staff manager example (relevant section starts p.324).
Everything works according to plan but QDataWidgetMapper will only display items from the QTreeView column 0 so only top level treeitems are displayed in the QDataWidgetMapper.
I initiate the QDataWidgetMapper with;
mapper->setModel(mytreemodel);
mapper->setRootIndex(myTreeView->rootIndex() );
//connect model to mapper
QDataWidgetMapper *mapper = new QDataWidgetMapper(this);
mapper->setModel(mytreemodel);
mapper->setRootIndex(myTreeView->rootIndex() );
//connect model to mapper
connect(myTreeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
mapper, SLOT(setCurrentModelIndex(QModelIndex)));
To copy to clipboard, switch view to plain text mode
With this setup only top nodes will be displayed! I've tried with
connect(myTreeView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
mapper, SLOT(setCurrentModelIndex(QModelIndex)));
To copy to clipboard, switch view to plain text mode
and
connect(myTreeView->selectionModel(), SIGNAL(currentColumnChanged(QModelIndex,QModelIndex)),
mapper, SLOT(setCurrentModelIndex(QModelIndex)));
To copy to clipboard, switch view to plain text mode
and both of them at the same time but no luck.
Any idea out there how I can get the QDataWidgetMapper to change with the QTreeView selection change?
Thanks
Bookmarks