johan07
2nd January 2013, 22:19
Hi,
i create list view , i set model to the list like that
listView->setModel( model );
i createthe model like that
void MainWindow::createModel()
{
model = new QStandardItemModel( 0,0,this );
model->setHorizontalHeaderLabels( QStringList() << "liste" );
createModelItems();
}
void MainWindow::createModelItems()
{
QStringList choiceList;
QStandardItem *pItem;
choiceList << "conf1" << "conf2" << "conf3";
foreach( QString str, choiceList ){ // parent
pItem = new QStandardItem( str );
pItem->setTristate( true );
model->appendRow( pItem );
}
}
and i added new item like that with signal slot
the sig,al is
void MainWindow::add(vector3 point)
{
QStandardItem *item=new QStandardItem(QString ("Marker %0").arg(nb_mark));
nb_mark++;
emit itemAded(item);
}
the slot is
void MainWindow::itemAded( QStandardItem *pItem )
{
model->appendRow( pItem );
}
but the problem is that it add to me new item and that's not what i want
i want to add the new item as child of an item of the "chois list"
i know that i must add this infiormation in the signal , but how i do that ? have you an idea ?
i create list view , i set model to the list like that
listView->setModel( model );
i createthe model like that
void MainWindow::createModel()
{
model = new QStandardItemModel( 0,0,this );
model->setHorizontalHeaderLabels( QStringList() << "liste" );
createModelItems();
}
void MainWindow::createModelItems()
{
QStringList choiceList;
QStandardItem *pItem;
choiceList << "conf1" << "conf2" << "conf3";
foreach( QString str, choiceList ){ // parent
pItem = new QStandardItem( str );
pItem->setTristate( true );
model->appendRow( pItem );
}
}
and i added new item like that with signal slot
the sig,al is
void MainWindow::add(vector3 point)
{
QStandardItem *item=new QStandardItem(QString ("Marker %0").arg(nb_mark));
nb_mark++;
emit itemAded(item);
}
the slot is
void MainWindow::itemAded( QStandardItem *pItem )
{
model->appendRow( pItem );
}
but the problem is that it add to me new item and that's not what i want
i want to add the new item as child of an item of the "chois list"
i know that i must add this infiormation in the signal , but how i do that ? have you an idea ?