How to increment Image name ?
-
@jsulm said in How to increment Image name ?:
Actually it should :-)
Okay, I never used
QCameraImageCapture
, so I supposed the ID would be the ID of the used camera and not if the image...
Maybe I should avoid the reply to posts for topics I not experimented in! -
@KroMignon Sir, your solution helped me, so i think you should keep relying to this kind of posts :D, i have one last question, @jsulm how can i use my own id variable ? should i create a variable inside this class ? i don't understand !
-
@hamzaelazizi said in How to increment Image name ?:
should i create a variable inside this class ?
Yes and you initialize it with 0. Each time your slot is called you increment it and check whether it is bigger than the max id value you want to use, if it is you set it back to 0.
-
@jsulm something like this ?
QObject::connect(_image_capture.data(), &QCameraImageCapture::imageCaptured, [=] (int id=0, QImage img) { int idx = 0; if(idx>=11) { idx=0; } else { idx++; } QString fileName = QString::number(idx) + ".png"; QString path = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + "/" + fileName; img.save(path, "PNG"); });
Because i've tried this and it didn't work :/
-
@hamzaelazizi said in How to increment Image name ?:
something like this ?
No.
In your code idx is a local variable and not a class member... -
I have updated my previous post. Please, try it again.
-
@hamzaelazizi Depends what you write and where.
-
@hamzaelazizi said in How to increment Image name ?:
outside the method
I never suggested to declare it outside of the method. I suggested to declare it as a class member:
class YOUR_CLASS: { private: int idx{0};