The following is a fairly hacky workaround, but was enough for me to get it working.
I modified the qml files to import both QtGraphicalEffects
and Qt5Compat.GraphicalEffects
.
Then, in my initialization C++ code I added
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qmlRegisterModule("QtGraphicalEffects", 1, 15); // or any other version that you import
#else
qmlRegisterModule("Qt5Compat.GraphicalEffects", 1, 0);
#endif
Essentially qmlRegisterModule
just creates a dummy empty module. Therefore one of the imports works and one does nothing (and which one is the working one depends on the Qt version).
I also tried a different scheme with qmlRegisterModuleImport("QtGraphicalEffects", ...)
but this didn't work well, possibly because my empty QtGraphicalEffects
module had no qmldir
, I'm not completely sure here... This would be cleaner (let you keep the QML code the same) but it seems to be a dead end.