ChatCrawlersearch across public Telegram Open the app
Q

Qt for Python (PySide/Shiboken)

snapshot for December 2019
‹ December 2019 ›×
28 December 2019
F
I hear there's this nice ancient protocol called IRC, where spam isn't a problem anymore since Freenode fixed things :D
C
The more protocols the merrier, right? 😁
29 December 2019
C
PSA: Since 5.14 is finally out, take into consideration that pyside2-uic and -rcc are now just a wrapper around Qt's binaries, so it could be that many features are still not in place, or missing from them.
30 December 2019
U
Guess I can ask some technical questions here? 🤓
I have a QML + PySide2 sketch with ListView and SwipeView sharing the same model - subclass of QAbstractListModel. List represents, well, a list of projects and SwipeView represents the selected project in expanded view with control buttons, elements, etc. Each element of the model is QObject subclass and I have no problems accessing its Python properties from QML using @Property() decorator. But how can I call its methods? Yea, sure, I can define @Slot in QAbstractListModel and it will be called with the given index, and then redirect the action to my underlying QObject subclass. But it is definetely not very elegant solution. Then, I will need to return some data (logs) back to QML and what? Will be need to create some global handler that will dispatch the message to the widget by its index, access widgets hierarchy... Doesn't look like a legit architecture at all actually.
Would be great to do all the stuff related to the particular QObject in its class, not bothering QAbstractListModel
U
I can provide some code to make the thoughts clearer
so, I guess you looked at the couple of examples we have for QML and Python interaction, right?
at least it's on my todo list to do a list-based qml/python tutorial :/ but I haven't had time tbh.
I would recommend you to use Properties to get a straightforward communication
iirc we had an example where you can have a property from a class living in python exposed to qml
U
Thanks, I'll give it a look! So basically it's like a model inside a model?
C
Kind of, but please let us know if we can help you more. You described a quite precise schema, so I would like to cover that in some tutorial if possible
31 December 2019
So, I finally have a proof-of-concept now. The code is kind of messy currently cause I've tried so many things to get it work. In two words: to be able to directly invoke methods of the internal model (`QObject`-derived element inside a ListView`) I define property of my custom registered type and then simply reference it in QML handlers (such as `onClicked`). The tricky part was to add `result argument in Slot definition, otherwise the call returns nothing. And to emit a signal from the Python internal model and catch it in QML ListView element I've used a straightforward signal: Connections { target: listItem // this is a property representing a single list element onLogAdded: { log.append(message); } }
There are still some issues, in particular in some timings and addressing desired widgets, but I think they can be resolved eventuallly.
Maybe I’ll ask in the future 🙂
I didn't find these suggestions in the links you've mentioned, unfortunately, but you initiated a new mind flow in correct direction, thanks!
The progress goes really slow actually, especially comparing to the old QWidgets approach, but I think the architecture in general will be cleaner at long last.
Also, looks like a PySide2 enables QML debugging feature by default, at least on macOS, and this is very useful. PyQt is completely silent by default. But on Win7 both of them are quiet (I use PyCharm on both).
U
Btw, I've asked about native look in QML for about a month ago, and yes, QtQuick 1.0 has this feature, though the design in still not native, just mimicking, so I stick with current QtQuick version (2+)
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