[PyQt] QML types registered as QtQuickItems not following Row/Column positioning
Louis Simons
lousimons at gmail.com
Fri Dec 23 02:58:48 GMT 2016
I've been learning (mostly trial and error) PyQt5 with a project at
https://github.com/superlou/snowman-qt-client. I've tried to do the view
layer in QML, with components that need a model backend defined in Python
and registered. For example, the MainBus QML type is registered as a
MainBus Python class. The MainBus Python object then handles some business
logic communication to the backend server. The only gotcha I'm running
into is that it seems like the custom QML items extending QtQuickItems
don't get positioned properly using layouts or anchors. I can set x and y
positions on them, but that's about it.
Is this expected behavior? I'm starting to think that maybe the intent of
registering types is not to directly link a QML "view" to a Python "model."
Is there a more appropriate way to create this kind of architecture?
Would it be more appropriate to create a MainBusModel class, that's used
purely as a property of a QML MainBus view? Another part of me is thinking
that I missed the boat altogether, and that my registered type should
really be the ManagerConnection (
https://github.com/superlou/snowman-qt-client/blob/master/manager_connection.py),
which is really what the Python object is interacting with, and almost all
of my logic could be handled in QML.
I apologize if this is a basic question. I've been reading the C++
documentation, and while it says "how" to do things, it doesn't really
recommend how you structure these kinds of apps.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20161223/66def834/attachment.html>
More information about the PyQt
mailing list