SAVE AND LOAD image in Directory
-
wrote on 25 Aug 2016, 16:06 last edited by
Hello
before i wanted to save users pictures in my database
and i searched on web and seen that this work doing database heavy for loading
and this better to save images on Directory and save Image path to Table
and load it From Directory!i write this code for save image but do nothing!
QImage originalPixmap; originalPixmap.save("D:\\Projects\\physiotherapy\\sickpic"+filename);
any body can help me please?
-
wrote on 25 Aug 2016, 16:56 last edited by
the folder tree should exist (QImage will not create folders) and
filename
should contain the extension otherwise you have to provide it as second argument -
the folder tree should exist (QImage will not create folders) and
filename
should contain the extension otherwise you have to provide it as second argumentwrote on 25 Aug 2016, 16:57 last edited by M4RZB4Ni@VRonin
but folder is exist and image doese not save :|
with this code i chek the path:void Medical_Records::createFolderPath() { QDir createfolder("D:\\Projects\\physiotherapy\\sickpic"); if(!createfolder.exists()) { createfolder.mkpath("D:\\Projects\\physiotherapy\\sickpic"); } } vo
-
wrote on 25 Aug 2016, 17:02 last edited by
2 questions:
- does
originalPixmap.isNull()
return true? - what is the content of
filename
?
- does
-
wrote on 25 Aug 2016, 17:09 last edited by VRonin
1: could you try
Q_ASSERT(!originalPixmap.isNull());
(this should cause a "crash" in your application if the image is null)
2: your are missing a/
try also to specify the format:originalPixmap.save("D:/Projects/physiotherapy/sickpic/"+filename,"PNG");
-
wrote on 25 Aug 2016, 17:19 last edited by
thanks:)
with this note:- 2: your are missing a / try also to specify the format: `originalPixmap.save("D:/Projects/physiotherapy/sickpic/"+filename,"PNG");*
Saving Problem Solved
But if i want to write a code to if picture exists show message and with yes/no
if user clicks on the yes overwrite pic
Thanks a lot:)
- 2: your are missing a / try also to specify the format: `originalPixmap.save("D:/Projects/physiotherapy/sickpic/"+filename,"PNG");*
-
wrote on 25 Aug 2016, 17:21 last edited by
if(QFile::exists("D:/Projects/physiotherapy/sickpic/"+filename)) //ask
-
wrote on 25 Aug 2016, 20:32 last edited byThis post is deleted!
4/10