[SOLVED] Best practice to connect signals between objects created using the qmlRegisterType() method?



  • Hi,

    I have a problem by getting a segmentation fault when connecting a signal between two objects defined by qmlRegisterType(). I know that it's probably beause the objects aren't created when I'm trying to call the Connect (...) method.

    What is the best practice to connect signals between objects that are created in the QML context through the qmlRegisterType() method?

    Shall I emit a signal in Component.onCompleted and make a slot where all my connection is called or is there a signal emitted automatically from the QML context when all objects defined in QML are created?

    I know that the objects are created since I use the objects in the qml file.. I make a qDebug() in the constructor that is executed...

    Any advice is appreciated !
    Fredrik



  • I choose a more simpel approach by skipping the qmlRgisterType() ..

    I create all instances in the c++ context and do ..

    MyClass class;
    QQmlContext *ctxt = view.rootContext();
    ctxt->setContextProperty("MyClass", &class);

    // Setup signals and slots..

    /Fredrik


Log in to reply
 

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