connect table cell to QLabel
Unsolved
General and Desktop
-
Hello,
I have a QAbstractItemModel model where I create dynamically QLabels and rows by a pushButton, I am trying to connect text on column 0 to each QLabel, so that if I change for example text in position 0,1 QLabel labels[0] is automatically updated, I tried this:
for(int i=0;i<model->rowCount(QModelIndex());i++){ QModelIndex idx = model->index(i,0); connect(model->data(idx),SIGNAL(textChanged(const QString &)),&labels[i],SLOT(changeText())); }
but it does not compiles, how could I solve this?
Thank you everyone!
-
Hi,
Why are you using QLabels rather than an a QListView to show these texts ?
From the looks of it, you are trying to connect QVariant objects which will not work.
-
You can either use the
DecorationRole
to show them or a custom QStyledItemDelegate