PDA

View Full Version : TreeView click item not connecting



Big Duck
9th June 2006, 17:59
Hi,

I have a treeview connected to a standardItemModel
I want to connect a click on an item do do something with current index.


treeView = new MyTreeView;
model = new QStandardItemModel(0,12);

treeView->setSelectionBehavior(QAbstractItemView::SelectRows );
treeView->setSelectionMode(QAbstractItemView::SingleSelectio n);
treeView->setEditTriggers(QAbstractItemView::NoEditTriggers) ;
treeView->setModel(model);
treeView->header()->setClickable(true);
connect(treeView, SIGNAL(clicked()), this, SLOT(doGameInfo()));


Ive got some rows in the model and I click on a row, nothing happens.
My connect should work should'nt it ?

I dont see why the index could be invalid so thats not the problem ?



public:
QTreeView *treeView;
private slots:
void doGameInfo();


I even tried sub classing QTreeView to re-code :
void clicked ( const QModelIndex & index );

but no luck, any pointers anyone ?
Thanks, Neil

Jimmy2775
9th June 2006, 18:19
You might want to change the signature of the signal coming from the QTreeView. It should be:

connect(treeView, SIGNAL(clicked( QModelIndex )), this, SLOT(doGameInfo()));

If you don't include the data types of the parameters passed by the signal, Qt won't recognize it.

Big Duck
9th June 2006, 19:38
Thanks, I new it had to be something so simple as that!

i had tried - obviously needed more sleep , less programming :)


connect(treeView, SIGNAL(clicked( const QModelIndex & index ), this, SLOT(doGameInfo()));


many thanks.