O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding the elements business object

The first thing that we might want to do is create an elements business object to encapsulate operations on a collection of Element entities. We implement it as a simple QtObject, by adding:

  • A list property to keep reference to the elements that we have added to the composition
  • A selectedElement string to keep track of the objectName for the currently selected Element
  • A counter integer to generate unique, progressive objectNames for the entities
  • A factory property of type Component to reference the QML Component in charge of generating Element instances:
// cccomposer/main.qml...Window {    ...    QtObject {        id: elements        property int counter: 0        property string selectedElement        property var list: [] readonly ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required