Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
"Not responsing..." window when using lots of data
I develop a program which cipher and decipher any file (Project "CryptoFiler". After some experiments i figured out that there is a "not responsing..." at the window when I load a program with 5 MB or more. I was thinking about using QThread, but I'm not very confident with multithreading yet.
I have to wait until the algorithm is done with (de)cipher progress, then I can continue with it. I fear that some users may try to quit the program by force when the program can't respond. Any suggestions?
PS: As an improvement I thought about adding a progress bar. After the first test (2 KB) it took longer than without one. If you have a solution for that then very thank you.
Hostel last edited by
Show the user a message - "Work in progress - don't close the application. It may take a few minutes." The simplest things are often the best :)
john_god last edited by
Have a look at QCoreApplication::processEvents() . It's much simpler than multithreading.
tzander last edited by
I suggest a thread, yes.
andre last edited by
Because I think it won't be easy to break up the decryption into smaller blocks, I think using a thread is your best bet. Note that you could use one of high-level primitives. Instead of using a QThread directly, you could consider using QtConcurrent::run. That returns a [[doc:QFuture]], on which you can create a [[doc:QFutureWatcher]] to get a signal when the task is done.
Thanks for your suggestions. I will try all of them and choose the one I think is the best.
When the application is ready after some tests I will create a Linux (and maybe a Mac OS) version of it. The algorithm uses binary mode for reading/writing.
That sure is the simplest way ^^
I never thought about using a different process, though I used it in a Raytracing algorithm for computer graphics to safe time (1920x1080 sure takes its time).
I can't break them up. If I do, the application might write data blocks in wrong order.
I read a block from std::ifstream, cipher it and write it into std::ofstream. That way I don't have to allocate anything into the memory (25 MB was highest according to Microsoft Task Manager).
I still need to try the QThread way. I found two different ways to create threads:
Create a QObject which has at least one signal to show that the thread is finished and connect it to a thread (Zander's link). Then use QThread::start();
Create a class which is derived from QThread and write the function into protected "run" method. Then use QThread::start();
Two different parties and all of them says that the other one it the wrong way. What shall I believe now.
I tried to create a QMessageBox with a message that it might take longer. A message box appeared, but except for the titel there only was a blank window without a text (see code below). As another solution I could use a QLabel which says "Please wait..." during the process and disappears afterwards.
@QMessageBox msg(QMessageBox::NoIcon, "Cipher process", "Process may take some time. Please wait...");
msg.setInformativeText("Process may take some time. Please wait...");
bool ok = crypto_->cipher(...);
I somehow can't manage to create another process where the cryptic process occures. it's different from <windows.h> library. I might get problems when i try to export this to Linux/Mac OS.
tzander last edited by
The suggestion to use signals is from the creator of the thread classes himself;
I agree with him, you practically never want to subclass QThread.
[quote author="Thomas Zander" date="1360153191"]The suggestion to use signals is from the creator of the thread classes himself;
I agree with him, you practically never want to subclass QThread.[/quote]
Ok, thanks for info. I have one last question:
The project's/program's name is "CryptoFiler". 2 days ago I heard that there already is a software called "Acid Cryptofiler" developed by french military . I don't know now if I can use the name or if there is a patent. Is there a website where I can find this out without payment?