I am using QDataWidgetMapper to map data to a QLineEdit and it works fine. When I use to map data to a QLabel it does not show any data in the label.I am trying to do it in the following way:
QDataWidgetMapper *testMapper=new QDataWidgetMapper();
testMapper->setOrientation(Qt::Vertical);
testMapper->setModel(testModel);
//setting the mapper values to the textboxes ----works fine
testMapper->addMapping(ui->LineEdit1,0);
testMapper->addMapping(ui->LineEdit2,1);
//setting it to qlabels
testMapper->addMapping(ui->label,3);----- does not work
testMapper->toFirst();
I am getting the values from the list and attaching the list to the QDataWidgetMapper, from the mapper I am using addMapping to append it to the textboxes. Could anyone let me know why it does not work with qLabels.
By default, each widget's user property is used to transfer data between the model and the widget. QLabel has no user property. You should use an additional addMapping()
function enables a named property to be used instead of the default user property.
testMapper->addMapping(ui->label,3,"text");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With