mmertama / FigmaQML

Converts Figma designs to QML/QtQuick
MIT License
200 stars 38 forks source link

Connecting signals in FigmaQmlInterface.hpp to another class #15

Closed l984-451 closed 4 months ago

l984-451 commented 4 months ago

Thank you for this great project. The recent updates are fantastic and the project is making my Qt app development much quicker.

I am relatively new to Qt/C++, so forgive me if the answer is obvious. I am trying to use the eventReceived signal in FigmaQmlInterface.hpp to run a function in another file. I have connected it to a slot in my Landing class constructor:

Landing::Landing(QObject *parent) :  QObject(parent) {
    bool connected = connect(FigmaQmlSingleton::instance(), &FigmaQmlSingleton::eventReceived, this, &Landing::onEventReceived);
}

However, my function onEventReceived never gets called. Printing connected returns true.

Am I doing this properly?

mmertama commented 4 months ago

Oops It looks like I have a bug.... that instance is not what it is supposed to be. I will look at that, but you get the correct instance from auto* singleton = engine.singletonInstance<FigmaQmlSingleton*>("FigmaQmlInterface", "FigmaQmlSingleton"); ... where engine is yout app's qqmlengine