Hello,

I'm trying to store an QPixmap picture in a sqlite BLOB field, but it not storing. I've already search on forum and google, but not shure about my problem. can someone help me?

only the picture do not store on table

Qt Code:
  1. QString file = QFileDialog::getOpenFileName(this, tr("Select an image"),".", tr("JPEG (*.jpg *jpeg)\n"
  2. "PNG (*.png)\n"
  3. "GIF (*.gif)\n"));
  4. QImage image = QImageReader (file).read();
  5. QPixmap pm = QPixmap::fromImage(image).scaled(ui->label1->width(), ui->label1->height());
  6. ui->label1->setPixmap(pm);
  7.  
  8. QString description = "picture description";
  9.  
  10. QSqlDatabase con = QSqlDatabase::addDatabase("QSQLITE");
  11. con.setDatabaseName(_DB);
  12. con.open();
  13.  
  14. QSqlQuery query;
  15. query.prepare("INSERT INTO pictures (picture, description) VALUES (?,?)"); // picture is a blob field
  16. query.bindValue(0,pm);
  17. query.bindValue(1,description);
  18. query.exec();
To copy to clipboard, switch view to plain text mode 

thanks!
Juliano