ChatCrawlersearch across public Telegram Open the app
Q

Qt for Python (PySide/Shiboken)

snapshot for November 2023
‹ November 2023 ›×
QML_IMPORT_NAME = "io.qt.textproperties" QML_IMPORT_MAJOR_VERSION = 1 @QmlElement class Backend(QObject): updated=Signal(str) def init(self): super().init() self.updated.emit("IM") if name == "main": CURRENT_DIRECTORY = Path(file).resolve().parent app = QGuiApplication(sys.argv) format = QSurfaceFormat() format.setSamples(4) QSurfaceFormat.setDefaultFormat(format) engine = QQmlApplicationEngine() engine.addImportPath(f"{os.path.dirname(file)}") QQuickStyle.setStyle("CStyles") engine.setOfflineStoragePath(os.fspath(CURRENT_DIRECTORY)) backend = Backend() engine.load(os.fspath(CURRENT_DIRECTORY / "main.qml")) engine.rootObjects()[0].setProperty('sender', backend) engine.quit.connect(app.quit) def handle_status_changed(status): if status == QQuickView.Error: QtCore.QCoreApplication.exit(-1) if not engine.rootObjects(): sys.exit(-1) sys.exit(app.exec())
this is my python code
pragma ComponentBehavior: Bound import QtQuick import QtQuick.Window import QtQuick.Controls import QtQuick.Controls.Material import QtQuick.Controls.Material.impl import QtQuick.LocalStorage Window { id: wcs width: 1024 height: 600 visible: true visibility: Window.AutomaticVisibility modality: Qt.ApplicationModal flags: Qt.Window property QtObject sender . . . Connections { target: sender function onUpdated(msg) { console.log("Hello"); } } Backend{ id: bridge }
there were various changes since then but i reverted all of them and its the pure code from then, but it's not working.
It seems that i need to ask if it is possible that a python class be used as @QmlElement for bridge inside qml and also emits signals to qml file and run a python qthread and communicate with signal and slot or not?
M
Because it might be a bug. I need to be more percise explaining this. I'm having a python main.py which is loading a qml main.qml file. It consists of a class. Inside class,s initiator i start a qthread the class is defined with @QmlElement and is being used as a bridge inside qml. There are @QtCore.slot(str) s which are connected to qml elements such as buttons. After clicking on button the slot will run correctly and pass a signal to qthread. The qthread has a signal inside, that is connected to main.py and returning results of theead to main.py there is a def inside main.py that is connected to qthread signal. From inside this def i emit result of qthread to qml connections{} The problem is that when i simply emit some string from qthread to main.py and emit that to qml it will be successful. But when i use a simple if clause inside qthreads def run(self): it emits the signal to main.py and i can print it there but then i cannot emit what i received to qml. Apologize about being some how long and complicated
M
Hey I am calling a model from 2 different positions in my QML app. Can I somehow get the parent in a way I can distinguish between the two places? I have to give back the "rowCount" different, one filtered, the other one unfiltered
K
Markus BauerHey I am calling a model from 2 different positions in my QML app. Can I somehow get the parent in a way I can distinguish between the two places? I have to give back the "rowCount" different, one filtered, the other one unfiltered
Ссылка
click to show
Not sure I fully understand, but if you're filtering - wouldn't a QSortFilterProxyModel for one of them be what you're looking for? There is a QML module that exposes QSortFilterProxyModel to QML that would help with that: https://github.com/oKcerG/SortFilterProxyModel However it has C++ backing to it. You could port it to PySide6 though.
M
Hmm I have a QAbstractTableModel as a backend I use it to show a Table and a Combobox. I retrieve the data from a backend I want to use differnt parameter, when "rowCount" gets called from Table and Combobox
M
But doesn't that mean I have to get all data first into QML before I can filter?
T
Yeah, hadn't realized it's about QML. Only really paid attention to the last message. Hmm seems weird that it doesn't work out of the box.
M
I would assume, that the parent gives me a hint I was going through the parent element with the debugger but did not found a name or something to use
T
QSortFilterProxyModel is the answer, though. It confuses me that it is not available to QML contexts.
M
Okay sorry, but in this example I have to load all data in advance, or I am wrong?
Calendar: November 2023
MoTuWeThFrSaSu12234536271689141011121314151651718101920102112223242526271281329130
Archive by month
Open in Telegram Каталог площадок Искать в ChatCrawler

A snapshot of an open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog