【发布时间】:2015-01-23 16:46:20
【问题描述】:
我正在使用 QDataWidgetMapper 将数据映射到 QLineEdit,它工作正常。当我使用将数据映射到 QLabel 时,它不会在标签中显示任何数据。我正在尝试通过以下方式进行操作:
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();
我从列表中获取值并将列表附加到 QDataWidgetMapper,从我使用 addMapping 的映射器将其附加到文本框。谁能告诉我为什么它不适用于 qLabels。
【问题讨论】:
标签: qt qt4 qt-creator