PDA

View Full Version : What is replacement for QAbstractFileEngine?



White_Owl
29th September 2021, 16:15
In Qt4 I was able to create my own system of resource files with QAbstractFileEngine.
This project now have to migrate to Qt6 and I see that this class is no longer exist in Qt?
Was it deprecated and replaced with something?
What is the modern way to create my own support for my own file systems?

Added after 13 minutes:

I found a lot of messages in different mail-lists that QAbstractFileEngine is indeed deprecated in 4.8 and removed in 5.0, but what is the modern way to do virtual file systems?

d_stranz
29th September 2021, 17:50
You may be able to derive from QFileSystemModel or implement something which uses QDir, QFile, and QFileInfo instead.

Alternatively, you may be able to add the Qt 4.8 source code for QAbstractFileEngine into your local project. It probably depends on whether the other classes it might use have changed in a way that make it incompatible with Qt 6. If you do add it locally, it would be a good idea to rename the files and the class to something that will not conflict with Qt itself. From the documentation of Qt5 changes, it sounds like this class might still exist internally, but it is no longer public.

White_Owl
29th September 2021, 22:10
Are there any examples on how to use QFileSystemModel as basis for virtual FS?

d_stranz
30th September 2021, 00:40
I found only one real example of subclassing (https://www.walletfox.com/course/customqfilesystemmodel.php) QFileSystemModel.

But I guess I don't really understand how your "system of resource files" works. Are these virtual entries that appear as part of the actual file system? That is, in a certain real directory, are there entries for real files as well as for virtual resource files? Or is your entire "file system" virtual - nothing in it represents a real directory and file hierarchy, everything is virtual?

White_Owl
30th September 2021, 12:03
The current system have two VFS (three if you count standard qrc file):

One works with database blobs as files:
File b("#articles/123/textField");
Means: open for read-write blob from table 'articles', from row with primary key 123. field 'textField'.

Second hides in itself an FTP protocol:
File f("@server/path/file");

That gives kind of convenient way to move data between network and database. IT certainly can be rewritten to a more traditional way, but...

d_stranz
30th September 2021, 15:41
IT certainly can be rewritten to a more traditional way, but...

I think your easiest solution might be to copy the code for QAbstractFileEngine from Qt 4.8, rename it, and see if you can build it using Qt 6. I don't have a Qt4 installation any more, so I can't check the source code.