- Qt 6.12
- Qt Qml
- QML Types
- QtObject
- Qt 6.12.0 Reference Documentation

# QtObject QML Type (Singleton)

A basic QML type. More...

Import Statement: | `import QtQml`
In C++: | QObject
Inherited By: | AbstractButton, Action, ActionGroup, AnimatedImage, AnimatedSprite, BorderImage, BusyIndicator, Button, ButtonGroup, Calendar, Canvas, CheckBox, CheckDelegate, ColorGroup, ColorOpacityAnimation, Column, ColumnLayout, ComboBox, Container, Control, DayOfWeekRow, DelayButton, Dial, Dialog, DialogButtonBox, DoubleSpinBox, Drawer, DropArea, EllipseShape, Filter, FlexboxLayout, Flickable, Flipable, Flow, FocusScope, Frame, FunctionFilter, FunctionSorter, Grid, GridLayout, GridView, GroupBox, HorizontalHeaderView, HorizontalHeaderViewDelegate, Image, ImageParticle, Item, ItemDelegate, ItemGrabResult, ItemParticle, Label, LayoutItemProxy, ListView, Loader, MaskShape, Menu, MenuBar, MenuBarItem, MenuItem, MenuSeparator, MonthGrid, MouseArea, MultiEffect, MultiPointTouchArea, Overlay, Page, PageIndicator, Palette, Pane, ParticlePainter, PathView, PinchArea, Popup, ProgressBar, RadioButton, RadioDelegate, RangeFilter, RangeSlider, Rectangle, RectangularShadow, RegExpFilter, Repeater, RoleFilter, RoleSorter, RoundButton, Row, RowLayout, ScrollBar, ScrollIndicator, ScrollView, SearchField, SelectionRectangle, Settings, ShaderEffect, ShaderEffectSource, Shape, Slider, Sorter, SpinBox, SplitHandle, SplitView, SpriteSequence, StackLayout, StackView, StandardPaths, StringSorter, SwipeDelegate, SwipeView, Switch, SwitchDelegate, SystemInformation, TabBar, TabButton, TableView, TableViewDelegate, Text, TextArea, TextEdit, TextField, TextInput, ToolBar, ToolButton, ToolSeparator, ToolTip, TreeView, TreeViewDelegate, Tumbler, ValueFilter, VectorImage, VerticalHeaderView, VerticalHeaderViewDelegate, WeekNumberColumn, and WindowContainer

Note: This type is a QML singleton. There is only one instance of this type in the QML engine.

- List of all members, including inherited members

## Properties

- objectName : string

## Detailed Description

The QtObject type is a non-visual element which contains only the objectName property.

It can be useful to create a QtObject if you need an extremely lightweight type to enclose a set of custom properties:

     import QtQuick

     Item {
         QtObject {
             id: attributes
             property string name
             property int size
             property variant attributes
         }

         Text { text: attributes.name }
     }

It can also be useful for C++ integration, as it is just a plain QObject. See the QObject documentation for further details.

## Property Documentation

### objectName : string

This property holds the QObject::objectName for this specific object instance.

This allows a C++ application to locate an item within a QML component using the QObject::findChild() method. For example, the following C++ application locates the child Rectangle item and dynamically changes its `color` value:

     // MyRect.qml

     import QtQuick 2.0

     Item {
         width: 200; height: 200

         Rectangle {
             anchors.fill: parent
             color: "red"
             objectName: "myRect"
         }
     }

     // main.cpp

     QQuickView view;
     view.setSource(QUrl::fromLocalFile("MyRect.qml"));
     view.show();

     QQuickItem *item = view.rootObject()->findChild<QQuickItem*>("myRect");
     if (item)
         item->setProperty("color", QColor(Qt::yellow));