PDA

View Full Version : Signal & Slot



LordQt
18th November 2007, 23:18
Hello friends,

i´am nearly ready with my treeview. To expand the child i must double click on the parent.
But i want expand it by one click so i implement this


privat slots:
void expand(const QModelIndex & index);


in my mainwindow i add this code:


connect(qtv, SIGNAL(clicked( const QModelIndex & index )),
this, SLOT(expand(const QModelIndex & index)));


and after all the implementation:



void MainWindow::expand(const QModelIndex & index)
{
if ( index.isValid())
{
qtv->expand(index);
}

}


But nothing happens. I must always doubleclick the parent item to expand the child.

Have anybody an idea what i make wrong??

wysota
18th November 2007, 23:22
Don't pass variable names to connect statements. Should be:

connect(qtv, SIGNAL(clicked( const QModelIndex & )), this, SLOT(expand(const QModelIndex &)));