vcp
15th September 2009, 15:47
Hi,
Sorry if this question already was debated but I'm with a big proble here:
I populate a QListView in this way:
QStandardItemModel *model = new QStandardItemModel;
int row=0;
for(int i=0; i<= files.size()-1;++i) {
if(files.at(i).isEmpty() )
break;
QStandardItem *item = new QStandardItem;
item->setText(files.at(i));
item->setIcon(QPixmap::fromImage(images->resultAt(i)));
item->setTextAlignment(Qt::AlignLeft);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
model->setItem(row, 0, item);
++row;
}
LV_IMAGES->setModel(model);
LV_IMAGES->show();
At this point all ok. Now I want remove a row from QListView LV_IMAGES them I use:
int r = LV_IMAGES->currentIndex().row();
//mdlThumbs->takeRow(r);
if( mdlThumbs->removeRows(r, 1,LV_IMAGES->currentIndex()) )
qDebug() << "OK";
else
qDebug() << "NO";
But nothing is happening and always returns "NO"
Were is the error?
Thanks in advance
Sorry if this question already was debated but I'm with a big proble here:
I populate a QListView in this way:
QStandardItemModel *model = new QStandardItemModel;
int row=0;
for(int i=0; i<= files.size()-1;++i) {
if(files.at(i).isEmpty() )
break;
QStandardItem *item = new QStandardItem;
item->setText(files.at(i));
item->setIcon(QPixmap::fromImage(images->resultAt(i)));
item->setTextAlignment(Qt::AlignLeft);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
model->setItem(row, 0, item);
++row;
}
LV_IMAGES->setModel(model);
LV_IMAGES->show();
At this point all ok. Now I want remove a row from QListView LV_IMAGES them I use:
int r = LV_IMAGES->currentIndex().row();
//mdlThumbs->takeRow(r);
if( mdlThumbs->removeRows(r, 1,LV_IMAGES->currentIndex()) )
qDebug() << "OK";
else
qDebug() << "NO";
But nothing is happening and always returns "NO"
Were is the error?
Thanks in advance