static const unsigned char image_6_data[] = { 0x00,0x00,0x07,0x90,0x78,0x9c,0xbd,0xd3,0x5b,0x4c,0x93,0x77,0x18,0x06, 0xf0,0xda,0x2d,0xbd,0x36,0x5e,0xec,0x00,0xa8,0xe0,0x89,0x7a,0x08,0x2a, ....};
QByteArray ba;QBuffer buf( ba );buf.open( IO_WriteOnly );yourImage.save( &buf, "XPM" );buf.close();QSqlQuery query;query.prepare( "ISERT INTO aTable (id, image) VALUES ( :id, :image )" );query.bindValue( ":id", imageId );query.bindValue( ":image", ba );query.exec();
void Form1::init(){QSqlQuery query;query.exec("SELECT image from tmp"); while (query.next()){ QPixmap pixmap( query.value( 0 ).toPixmap() ); image->setPixmap( pixmap ); } if(!query.isActive()){query.lastError().showMessage();}}
void Form1::init(){QByteArray ba;QSqlQuery query;query.exec("SELECT image from tmp where id = '1'");while (query.next()){ ba = query.value( 0 ).toByteArray(); QPixmap pixmap(ba); image->setPixmap( pixmap );} if(!query.isActive()){query.lastError().showMessage();}}