I have simple master detail application using QDataWidgetMapper in master table; I added a blob in database and QLable to show the picture and button to select a picture
The button code
this, tr("Open file"), "/MyDocument/", tr("PNG Images (*.jpg)") );
ui
->pix_label
->setPixmap
(QPixmap::fromImage(image
));
QString pix = QFileDialog::getOpenFileName(
this, tr("Open file"), "/MyDocument/", tr("PNG Images (*.jpg)") );
QImage image(pix);
ui->pix_label->setPixmap(QPixmap::fromImage(image));
To copy to clipboard, switch view to plain text mode
and the classic mapper code
mapper->setModel(model);
mapper->addMapping(ui->id,model->fieldIndex("id"));
mapper->addMapping(ui->fName,model->fieldIndex("fName"));
mapper->addMapping(ui->lName,model->fieldIndex("lName"));
mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->setItemDelegate(new QSqlRelationalDelegate(this));
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
mapper->addMapping(ui->id,model->fieldIndex("id"));
mapper->addMapping(ui->fName,model->fieldIndex("fName"));
mapper->addMapping(ui->lName,model->fieldIndex("lName"));
To copy to clipboard, switch view to plain text mode
Now, I tried to add this line but couldn't navigate pictures
mapper->addMapping(ui->picture_label,model->fieldIndex("picture"));
mapper->addMapping(ui->picture_label,model->fieldIndex("picture"));
To copy to clipboard, switch view to plain text mode
I need help to make that works, I'm a just beginner, so a detailed code is appreciated. Thanks in advance
Bookmarks