Pregunta

I have a QStandardModel. I connect its itemChanged signal to my own slot.

m_model = new QStandardItemModel(this);  
connect(m_model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(changed(QStandardItem*)));

The slot looks like this:

void Class::changed(QStandardItem * item) {
    //    ui->pushButton->setText("change");
    QString name = item->parent()->data().toString();
    ui->pushButton->setText(item->data().toString());
}  

The pushButton text will change to "change", so my slot seems to work. However, item->data().toString() is always empty.

How do I do this right?

¿Fue útil?

Solución

I think you should use QStandardItem::text() method. Like this: QString name = item->parent()->text();

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top