PDA

View Full Version : currentChanged protected slot - cant get working



Big Duck
11th June 2006, 23:13
Hi,

I've been playing with Qt 4.1.1 now for a few weeks, getting my app done.
Still a newbie however as i have a simple problem.

currentChanged protected slot on a treeView, I cant seem to get working
I have a treeView with some rows. I got clicked() working, but I really need a currentChanged to work when the row selected is changed.

here's some code below:



public:
QTreeView *treeView;
protected slots:
virtual void currentChanged (const QModelIndex & current, const QModelIndex & previous);

void GamesTab::currentChanged (const QModelIndex & current, const QModelIndex & previous)
{
doGameInfo();
}



What am I missing anyone ?

wysota
11th June 2006, 23:25
You should use signals and slots:


QTreeView *tv;
QItemSelectionModel *selmod = tv->selectionModel();
connect(selmod, SIGNAL( currentChanged ( const QModelIndex &, const QModelIndex &)),
this, SLOT(onCurrentChanged(const QModelIndex &)));
//...

void someClass::onCurrentChanged(const QModelIndex &current){
doGameInfo();
}