Home > Mobile >  import Qt5Compat.GraphicalEffects: QML module not found
import Qt5Compat.GraphicalEffects: QML module not found

Time:09-22

I am on Arch Linux and I am trying to use PySide6 and QT6 in my project since I will need to be able to use singleton qml objects and PySide2 doesn't seem to support the registration of singleton qml objects. My project uses ColorOverlays and DropShadows, so I will need GraphicalEffects support. However, according to the doc pages, these aren't supported by Qt6 and require a compatibility module, Qt5Compat.GraphicalEffects to be supported.

I am trying to import Qt5Compat.GraphicalEffects into my QML code via the import statement below:

import Qt5Compat.GraphicalEffects

However, when I add this to my project's QML in QT Creator, I am getting the error: "QML module not found."

Here are some things I have tried in order to remedy this issue:

  • Installed QT using the installer from the website.
  • Installed Qt6/5 via pacman.
  • Installed the qt6-5compat package from the AUR.
  • Installed qt6/5-base from the AUR.
  • Googling the issue.

How can I fix this issue with importing Qt5Compat.GraphicalEffects?

EDIT:

I am using Python and PySide6 for my backend code, but I am writing the front-end in QML, which is where I am having my issue.

CodePudding user response:

You have to keep in mind that PySide2 is a binding of Qt5 and PySide6 is that of Qt6.

If you want to use ColorOverlay or DropShadow with then you should follow the Qt5 documentation that says you should use import QtGraphicalEffects 1.15.

If instead you want to use it in it has moved those components to the Qt5Compat module so you should use: import Qt5Compat.GraphicalEffects.

So the way to import will depend on whether you are using PySide2 (Qt5) or PySide6 (Qt6).

Note: QtCreator does not have many capabilities so many times it will throw false positives since it is not able to understand PySide. Unfortunately they have not given it "much affection" so it is not optimized to work with python obtaining that type of warnings. So just obviate the warning.

  • Related