[PyQt] QML types registered as QtQuickItems not following Row/Column positioning

Cody Scott cody at perspexis.com
Tue Jan 3 16:35:08 GMT 2017


Where is the QML code that is not working? I think you might just be having
a problem with layout in QML. One thing to note is that by default
components don't have a width and a height so you need to either specify
them directly or with Layout.fillWidth: true

On Thu, Dec 22, 2016 at 9:58 PM, Louis Simons <lousimons at gmail.com> wrote:

> 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.
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170103/adfb38d8/attachment.html>


More information about the PyQt mailing list