Selecting multiple files for reading
-
@suslucoder said in Selecting multiple files for reading:
@JonB If I could think and do all of this at once, I wouldn't ask for help. You don't have to be this hard every time. I'm probably younger than you, and I'm making an effort to learn. It shouldn't be that hard to understand
I think I explained it very gently & clearly! And told you what you need to do, and explained what the term "iteration" is. So I'm sorry you feel like that, I believe I am one of the people here who is prepared to explain things the most! :) Maybe, if you can, don't take my words as harsh, because they are not intended like that! I'm a pussy cat really :-;
-
@Christian-Ehrlicher yes I don't know, is it a shame that I don't know?
-
@suslucoder Please start with basic c and c++ - everything else will not work out properly. And I'm pretty sure so will tell you the same.
-
@JonB I want to ask you something.
I did it in the way you said. Now i can select multiple files.
After selecting, i want to do some operations. But my code do it just for one file. The other files are not functional.Is there any way to do it like, do these for every different files.
I will share you my iteration, i hope it is correct:Q_UNUSED(b); QStringList fileNames; fileNames = QFileDialog::getOpenFileNames(nullptr, ("choose"), "up.sakla", ("choosen(*.up)")); for (auto xfile : fileNames) { QFile file (xfile); file.open(QIODevice::ReadOnly); QDataStream in(&file); // read the data serialized from the file QString str; qint32 a; qDebug() << str << a; in >> str >> a;
-
@suslucoder So, did you select more than one file? How many entries do you have in fileNames? Did you use debugger to see what happens?
Addfor (auto xfile : fileNames) { qDebug() << xfile;
to see what happens. There are so many things you can do to find out what happens...
-
@jsulm said in Selecting multiple files for reading:
qDebug() << xfile;
Yes i select and i can see them. I want to do such a thing:
do some operation
for every file that i select -
@suslucoder What do you think you print out to qDebug here:
QString str; qint32 a; qDebug() << str << a; in >> str >> a;
-
@suslucoder Do you really think the order of the two last lines is correct?
-
@suslucoder said in Selecting multiple files for reading:
I want to do such a thing:
do some operation
for every file that i selectso, what's stoping you ?