Image Fetching from database
Mobile and Embedded
2
Posts
2
Posters
656
Views
2
Watching
-
I faced one issue, image fetching from database to label button, but image doesn't appeared in the label button.
This is my code
void View::on_label_windowIconChanged(const QIcon &icon) { QSqlQuery qry; QPixmap pixmap = QPixmap(); int tempval; if(qry.exec(QString("SELECT product_image FROM product where active=1 AND categoryid=%1 order by productdescriptionterminal;").arg(tempval))) { qry.next(); QByteArray array = qry.value(0).toByteArray(); pixmap.loadFromData(array); ui->label->pixmap(); ui->label->show(); } }how to fix that issue, anyone can help me.
-
I faced one issue, image fetching from database to label button, but image doesn't appeared in the label button.
This is my code
void View::on_label_windowIconChanged(const QIcon &icon) { QSqlQuery qry; QPixmap pixmap = QPixmap(); int tempval; if(qry.exec(QString("SELECT product_image FROM product where active=1 AND categoryid=%1 order by productdescriptionterminal;").arg(tempval))) { qry.next(); QByteArray array = qry.value(0).toByteArray(); pixmap.loadFromData(array); ui->label->pixmap(); ui->label->show(); } }how to fix that issue, anyone can help me.
Hi @karthi-shan,
You didnt setPixmap. Apart from that check if the
QPixmapisnullafterloadFromData.