Layout for qquickitem in C++

  • Hi, I am looking for a way to lay out my c++ components that inherit from qquickitem. In qml, Item is equivalent to QQuickItem in c++. Are there c++ class for Row, Column, RowLayout, and ColumnLayout in qml ?

  • Although there are such c++ classes (QQuickLinearLayout for RowLayout, for example), they are not meant to be used directly (they are not 'public'). In my humble opinion, if you need an entire qml item to be an instance of a c++ class, there is something wrong with your approach. I suspect you're trying to do things imperative in a declarative land...

  • There could be many reasons to use QQuickItem from C++, but definitely, layout should be done on QML side.
    So @Ray-Gray mentioned about imperative (C++ mostly) and declarative (QML) approaches, but also we may thinking: QML -> visible, C++ -> invisible. Personally, it helps me to distinguish which technique shall I use for which part of an app.
    But if the app is simple, maybe it is no need for C++ at all.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.