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. Insertion Image in the Database.

Insertion Image in the Database.

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 895 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,

    How to image insert in the database. Already i insert one way. fetching time only path(string format) appeared. Image doesn't appeared.

    this is my code.

    if(qry.exec("SELECT groupname,imageurl FROM grouptable;"))
    {
    int recCount = 0;
    while( qry.next() )
    {
    recCount++;
    }

                        if(recCount>0)
                        {
                            qry.first();
                            qry.previous();
                            PRINT <<"Query sucess";
                            ui->list->clear();
                            ui->list->setFont(QFont("Ubuntu",10));
                            while(qry.next())
                            {
                                //adding the group name to the list view
                                ui->list->addItem(new QListWidgetItem(QIcon(qry.value(1).toString()),qry.value(0).toString()));
                            }
                        }
                        else
                        {
                            PRINT<<"table empty"<<endl;
                        }
                    }
    

    anyone help me.

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

      Hi,

      Did you check that the path are valid to create your icons ?

      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,

        This is my full code. I check it, valid path only. fetching time string only appeared.

                    if(db.open())
                    {
                        QSqlQuery qry;
                        PRINT<<QString("SELECT groupid FROM grouptable where groupname=\"%1\";").arg(group)<<endl;
                        //checking for the group id under the group name which is selected
                        if(qry.exec(QString("SELECT groupid FROM grouptable where groupname=\"%1\";").arg(group)))
                        {
                            int recCount = 0;
                            while( qry.next() )
                            {
                                recCount++;
                            }
        
                            if(recCount>0)
                            {
                                qry.first();
                                PRINT <<"Query sucess"<<endl;
                                tempval=qry.value(0).toInt();
                                groupid=tempval;
                            }
                            else
                            {
                                PRINT<<"table empty"<<endl;
                            }
                        }
                        else
                        {
                            PRINT <<"Error .." << db.lastError().text()<<endl;
        
                        }
        
        
                        PRINT<<QString("SELECT categoryname FROM category where groupid=%1 order by categoryid ASC;").arg(tempval)<<endl;
                        //checking the category name under that group id
                        if(qry.exec(QString("SELECT categoryname FROM category where groupid=%1 order by categoryid ASC;").arg(tempval)))
                        {
                            int recCount = 0;
                            while( qry.next() )
                            {
                                recCount++;
                            }
        
                            if(recCount>0)
                            {
                                qry.first();
                                qry.previous();
                                PRINT <<"Query sucess"<<endl;
                                ui->list->clear();
                                ui->list->setFont(QFont("Ubuntu",7));
                                while(qry.next())
                                {
                                    //adding categorys to list
                                    ui->list->addItem(qry.value(0).toString());
                                }
                            }
                            else
                            {
                                PRINT<<"table empty"<<endl;
                            }
                        }
                        else
                        {
                            PRINT <<"Error .." << db.lastError().text()<<endl;
        
                        }
                    }
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Where exactly in these query are you querying for an image ?

          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