Load Image From Db Problem
Unsolved
General and Desktop
-
@M4RZB4Ni
this is all of my codes:
see it and if you can correct it
.h file:QImage *pix; QImage originalPixmap; QPixmap outPixmap; QPixmap pxp; QGraphicsPixmapItem pixItem; QByteArray inByteArraye; QByteArray outByteArray;
.cpp file:
void Medical_Records::shootScreen() { QScreen *screen = QGuiApplication::primaryScreen(); if (const QWindow *window = windowHandle()) screen = window->screen(); if (!screen) return; originalPixmap=ui->graphicsView_2->grab().toImage(); updateGraphicView(); } void Medical_Records::initalizeVarables() { shootScreen(); QBuffer inBuffer( &inByteArraye ); inBuffer.open(QIODevice::WriteOnly); originalPixmap.save(&inBuffer,"PNG"); } void Medical_Records::readSkeletonPic() { moveToThread(readSkeletonPicThread); readSkeletonPicQry.exec("SELECT SskeletonPic FROM Patient_File WHERE SmeliCode='"+seMcode+"'"); readSkeletonPicQry.next(); outByteArray = readSkeletonPicQry.value(0).toByteArray(); //outPixmap = QPixmap(); originalPixmap.loadFromData(outByteArray,"PNG"); qDebug() << "outByteArray :" << outByteArray.size(); qDebug() << "outByteArray :" << originalPixmap.size(); outPixmap.fromImage(originalPixmap.fromData(outByteArray,"PNG")); scene->addPixmap(outPixmap); ui->graphicsView_2->setScene(scene); qDebug() << readSkeletonPicQry.exec(); readSkeletonPicThread->start(); }
-
@VRonin
yes of course
thanks so muchthis is code :
void Medical_Records::initalizeVarables() { shootScreen(); QBuffer inBuffer( &inByteArraye ); inBuffer.open(QIODevice::WriteOnly); originalPixmap.save(&inBuffer,"PNG"); } void Medical_Records::submitWithScreenShot() { initalizeVarables(); QSqlQuery sql; sql.exec("UPDATE Patient_File SET SskeletonPic='"+inByteArraye+"' WHERE SmeliCode='"+seMcode+"';"); }
-
yep, you should check QSqlQuery::bindValue
sql.prepare("UPDATE Patient_File SET SskeletonPic= :skp WHERE SmeliCode= :smc"); sql.bindValue(":skp",inByteArraye); sql.bindValue(":smc",seMcode); sql.exec();
this also prevents SQL Injection. You should never really use unescaped input directly to build the query string