How to bind to root context object signal from QML

Werolik

I'm creating QML application (QT 5.2)

Assume I have some object set as root context:

viewer.rootContext()->setContextObject(&view_model);

Now I want to bind to a signal of view_model from QML:

Connections {
    target: ??? WHAT SHOULD GO HERE ???
    onSignalStateChanged: console.log("signal")
}

Cannot figure out what should be the target.

Important: I don't want to use setContextProperty.

RSATom

It seems you can't use Connections if you don't have access to object instance (via context property for example). But you still could use following:

function onSignal() {
    console.log( "signal" );
}
Component.onCompleted: {
    onSignalStateChanged.connect( onSignal );
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to bind to a signal from a delegate component within a ListView in QML

From Dev

How to bind a property to a singleton object property from QML

From Dev

How to emit signal in context of specific QML Item from C++ code

From Dev

How to emit signal in context of specific QML Item from C++ code

From Dev

Windows Phone 8.1 Development: How to Bind Data from the Deserialized Json Root Object for the List View

From Dev

How can I listen to a C++ signal from QML?

From Dev

QML - connect a signal from c++ to qml

From Dev

How to bind a panel's data context to parent object in XAML?

From Dev

How can I access an object instance's context from within a predefined function passed to the "bind" method invoked on the instance?

From Dev

How to hide context root

From Dev

How to hide context root

From Dev

QML: Overriding a signal handler from other element

From Dev

How to bind MultiColumnTreeView from Syncfusion to BindingList(Of Object)?

From Dev

how to get fragment object from context

From Dev

How to get $rootElement from root Angular object

From Dev

How to get $rootElement from root Angular object

From Dev

How to use a custom Qt type with a QML signal?

From Dev

How to set property type of qml signal?

From Dev

How to set property type of qml signal?

From Dev

How I can send signal from MouseArea to parent object (TableView)?

From Dev

How to access a nested QML object from C++?

From Dev

How to invoke method of QML object from C++

From Dev

QML TableView: how to bind to selection.onSelectionChanged()

From Dev

How to bind data object

From Dev

How to bind a object into a array

From Dev

Is it possible to disconnect all slots from a signal in Qt5 QML?

From Dev

Sending a signal to a QML item from C++ (Qt5)

From Dev

Passing Q_GADGET as signal parameter from C++ to QML

From Dev

C++/QML: ListView is not updated on dataChanged signal from QAbstractListModel

Related Related

  1. 1

    How to bind to a signal from a delegate component within a ListView in QML

  2. 2

    How to bind a property to a singleton object property from QML

  3. 3

    How to emit signal in context of specific QML Item from C++ code

  4. 4

    How to emit signal in context of specific QML Item from C++ code

  5. 5

    Windows Phone 8.1 Development: How to Bind Data from the Deserialized Json Root Object for the List View

  6. 6

    How can I listen to a C++ signal from QML?

  7. 7

    QML - connect a signal from c++ to qml

  8. 8

    How to bind a panel's data context to parent object in XAML?

  9. 9

    How can I access an object instance's context from within a predefined function passed to the "bind" method invoked on the instance?

  10. 10

    How to hide context root

  11. 11

    How to hide context root

  12. 12

    QML: Overriding a signal handler from other element

  13. 13

    How to bind MultiColumnTreeView from Syncfusion to BindingList(Of Object)?

  14. 14

    how to get fragment object from context

  15. 15

    How to get $rootElement from root Angular object

  16. 16

    How to get $rootElement from root Angular object

  17. 17

    How to use a custom Qt type with a QML signal?

  18. 18

    How to set property type of qml signal?

  19. 19

    How to set property type of qml signal?

  20. 20

    How I can send signal from MouseArea to parent object (TableView)?

  21. 21

    How to access a nested QML object from C++?

  22. 22

    How to invoke method of QML object from C++

  23. 23

    QML TableView: how to bind to selection.onSelectionChanged()

  24. 24

    How to bind data object

  25. 25

    How to bind a object into a array

  26. 26

    Is it possible to disconnect all slots from a signal in Qt5 QML?

  27. 27

    Sending a signal to a QML item from C++ (Qt5)

  28. 28

    Passing Q_GADGET as signal parameter from C++ to QML

  29. 29

    C++/QML: ListView is not updated on dataChanged signal from QAbstractListModel

HotTag

Archive