Qt problem: no QProgressBar animation with minimum and maximum steps set to 0

I have a problem with my QProgressBar and I hope someone has an idea ...

I created a progress dialog with QProgressBar myself. I set the minimum and maximum steps to 0, so progress indicates that my program is busy (animated thing ...).

I will show () this run dialog and activated Qt :: WindowModal for this dialog.

Problem: I use this dialog box when copying files, but the progress bar stops and there is no more animation to indicate that my program is still busy. I use the Windows "SHFileOperation" function to copy a single directory with a large number of files to the destination. This, of course, places a heavy strain on the system, but at least progress must continue.

Any help is appreciated!

Thanks in advance, BearHead

+3
source share
1 answer

The problem is that the call SHFileOperationblocks the main event loop. Therefore, no events will be processed, preventing the update QProgressBar.

, . - Qt Concurrent, , :

QFuture<void> future = QtConcurrent::run(SHFileOperation, ...);
QFutureWatcher<void> watcher;
connect(&watcher, SIGNAL(finished()), dialog, SLOT(close()));

, dialog .

Btw, SHFileOperation , QDir QFile?

+7

Source: https://habr.com/ru/post/1768614/


All Articles