Qt file loading
-
QT 6.10.0 Windows
Hi, I wanted to ask if in qt6 ssh connection changed somehow. It's much slower now I use ssh to connect to server and download files and in qt5 it was much faster. -
@jsulm This is not about QtCreator’s SSH, but about SSH usage inside my application after migrating from Qt 5.15 to Qt 6.10 (Windows). My app connects to a server via SSH, scans remote directories, downloads files, and populates a QTreeWidget. With the same code, Qt 6 is significantly slower than Qt 5, and the app can crash if the file browser is closed while remote loading is still in progress.
I now Qt6 is way stricter with threads etc than Qt5
-
Okey maybe I found the fix. Runs the whole thing in a background thread. Not sure about this but it help the speed but I need to debug it more
New version here, old one didn't use QtConcurrentif (ssh) { QPointer<FDirBrowser> guard(this); QtConcurrent::run([guard, ssh, subdir, url, currentDir, currentRow]{ // Code here DirDownloadControlCallback ctrl; FRemoteHost::DirNode dp = ssh->getDirListing(subdir, "*", config_DirDepth, &ctrl); QMetaObject::invokeMethod(qApp, [guard, dp, subdir, url, currentDir, currentRow]{ if (!guard) return; // Code here }, Qt::QueuedConnection); });EDIT: Still it has some problems but is way faster
-
OK, I found the real issue. I was calling processEvents() for every file during loading.
As far as I understand, processEvents() was rewritten or made heavier in Qt 6, and it is significantly slower than it was in Qt 5.
Reducing the calls to once every ~20 files (or batching them) improves performance a lot. -
OK, I found the real issue. I was calling processEvents() for every file during loading.
As far as I understand, processEvents() was rewritten or made heavier in Qt 6, and it is significantly slower than it was in Qt 5.
Reducing the calls to once every ~20 files (or batching them) improves performance a lot. -
@jsulm In what situations should I use it then. I know it can create some problem, but are they times when its good to use it?
-
@jsulm In what situations should I use it then. I know it can create some problem, but are they times when its good to use it?
@aabb2137 said in Qt file loading:
but are they times when its good to use it?
I don't think so. It is usually used as a quick workaround. However, you should rather restructure your code (usually using multi-threading) to avoid having to call processEvents. The most common place where this is used as a workaround is in loops to update the progress bar. The computation could be done a 100 times faster without calling processEvents.
-
@aabb2137 said in Qt file loading:
but are they times when its good to use it?
I don't think so. It is usually used as a quick workaround. However, you should rather restructure your code (usually using multi-threading) to avoid having to call processEvents. The most common place where this is used as a workaround is in loops to update the progress bar. The computation could be done a 100 times faster without calling processEvents.
@SimonSchroeder said in Qt file loading:
The most common place where this is used as a workaround is in loops to update the progress bar
To be more precise: I think the only "valid" use case are splash screens with progress bars that show the initialization process of your app in main... There you don't have your app loop running and you might have some plain backend stuff going on.
Then you can callprocessEvents()to update your splash screen (when e.g. a separateQEventLoopis no option) -
A aabb2137 has marked this topic as solved