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

Image Fetching

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 3 Posters 1.1k Views
  • 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
    #1

    Hi All,

    Image fetching Sqlite database to label button its working fine. But at the run time i can able to fetch one image only, i need to fetch multiple image. Any one can help me.

    My code is here:
    void MainWindow::on_pushButton_3_clicked()
    {
    int id;
    if(myDB.open())//opening database
    {
    QByteArray array;
    QSqlQuery query("SELECT id,img FROM vkks");
    query.next();
    for( int i =1; i <= 2; i++ )
    {
    qDebug() << "value of id: " << id << endl;
    array = query.value(1).toByteArray();
    qDebug()<<0;
    id=query.value(0).toInt();
    qDebug()<<array;
    QPixmap pixmap = QPixmap();
    pixmap.loadFromData(array);

            ui->label_4->setNum(id);
            ui->label->setPixmap(pixmap);
            qDebug()<<id;
    
        }
    }
    

    }

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It's all described in the QSqlQuery doc:

      while (query.next()) {
              //Do what you want with the database returned value
      }
      

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • K Offline
        K Offline
        karthi shan
        wrote on last edited by
        #3

        Hi,

        if i used within while loop, i can able to fetch last image only appeared, middle of the image is, i cant able to fetch.

        while (query.next())
        {
        array = query.value(1).toByteArray();
        id=query.value(0).toInt();
        QPixmap pixmap = QPixmap();
        pixmap.loadFromData(array);
        ui->label_4->setNum(id);
        ui->label->setPixmap(pixmap);
        }

        1 Reply Last reply
        0
        • jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Well, you always put your current image into the same label:

          ui->label_4->setNum(id);
          ui->label->setPixmap(pixmap);
          

          That's why you see only the last image.
          You could use one label for each image.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          K 1 Reply Last reply
          0
          • jsulmJ jsulm

            Well, you always put your current image into the same label:

            ui->label_4->setNum(id);
            ui->label->setPixmap(pixmap);
            

            That's why you see only the last image.
            You could use one label for each image.

            K Offline
            K Offline
            karthi shan
            wrote on last edited by
            #5

            @jsulm

            Hi,

            If i put each image each label mean, i need to put 300 label button, its possible???? for single form???? else, have any other way, please tell me????

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Create them dynamically in C++

              Or maybe consider using the Graphics View framework depending on the needs of your application

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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