Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Image Fetching from database
Qt 6.11 is out! See what's new in the release blog

Image Fetching from database

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 2 Posters 1.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    karthi shan
    wrote on last edited by p3c0
    #1

    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.

    p3c0P 1 Reply Last reply
    0
    • K karthi shan

      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.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @karthi-shan,

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

      157

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved