Issue
I'm trying to add a FileDialog
in QML, my environment:
- Python 3.10.8
- PyQt6
- Arch Linux
qt6-base
,qt6-declarative
packages installed
Code:
main.qml
import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Dialogs
Window {
Rectangle {
id: mainRect
anchors.fill: parent
Button {
text: qsTr("Open File")
onClicked: fileDialog.open()
}
}
FileDialog {
id: fileDialog
}
}
main.py
import os
import sys
from PyQt6.QtGui import QGuiApplication
from PyQt6.QtQml import QQmlApplicationEngine
def main():
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.load(os.fspath(Path(__file__).resolve().parent / "qml/main.qml"))
if not engine.rootObjects():
sys.exit(-1)
sys.exit(app.exec())
if __name__ == "__main__":
main()
When I try to run it produces this error:
file:///main.qml:20:5: QML FileDialog: Failed to load non-native FileDialog implementation:
qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/qml/FileDialog.qml:4 module "Qt.labs.folderlistmodel" is
not installed
Segmentation fault (core dumped)
I've tried searching the package repo and pypi to find if there's an extra package that contains this folderlistmodel but I couldn't find any.
Solution
I've tried FileDialog
on Windows and it works fine, it seems like an Arch Linux packaging issue but I'm not sure where to report.
I've used a workaround mentioned in this answer using tkinter
and it works fine on both OSs.
Answered By - Arsany Samuel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.