PDA

View Full Version : Add new item to a QListView



graciano
18th August 2009, 15:33
Hi
I have a QListView associated to a QStringListModel.


void txtEdit::addChar()
{
QString testChar("x");
int row = m_ui->usedList->currentIndex().row() + 1;
usedListModel->insertRows(row, 1);
QModelIndex index = usedListModel->index(row);
m_ui->usedList->setCurrentIndex(index);
m_ui->usedList->edit(index);
}


Line 8 allows me to type the content inside the QListView.
Could't find a way to write testChar instead of editing the item!
Where showld i look to find the solution for this?
Thanks

Lykurg
18th August 2009, 18:32
use QStringListModel::setData() for setting data to your model.

graciano
18th August 2009, 18:49
Perfect!
I was looking in the view and not in the model.
THAAANKKSS :D