I think you should use QStandardItem::text()
method. Like this: QString name = item->parent()->text();
Qt Signals & Slots: How do I get the data which was changed?
-
09-10-2022 - |
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?
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow