Nominate our 2022 Qt Champions!

Image Fetching from database

  • 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)))
            QByteArray array = qry.value(0).toByteArray();

    how to fix that issue, anyone can help me.

  • Moderators

    Hi @karthi-shan,

    You didnt setPixmap. Apart from that check if the QPixmap is null after loadFromData.

Log in to reply