Hi,
i create list view , i set model to the list like that
listView->setModel( model );
listView->setModel( model );
To copy to clipboard, switch view to plain text mode
i createthe model like that
void MainWindow::createModel()
{
model
->setHorizontalHeaderLabels
( QStringList() <<
"liste" );
createModelItems();
}
void MainWindow::createModelItems()
{
choiceList << "conf1" << "conf2" << "conf3";
foreach
( QString str, choiceList
){ // parent pItem->setTristate( true );
model->appendRow( pItem );
}
}
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 );
}
}
To copy to clipboard, switch view to plain text mode
and i added new item like that with signal slot
the sig,al is
void MainWindow::add(vector3 point)
{
nb_mark++;
emit itemAded(item);
}
void MainWindow::add(vector3 point)
{
QStandardItem *item=new QStandardItem(QString ("Marker %0").arg(nb_mark));
nb_mark++;
emit itemAded(item);
}
To copy to clipboard, switch view to plain text mode
the slot is
{
model->appendRow( pItem );
}
void MainWindow::itemAded( QStandardItem *pItem )
{
model->appendRow( pItem );
}
To copy to clipboard, switch view to plain text mode
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 ?
Bookmarks