How to press qtButton?

today I’m trying to press a button by code.

and i know the name of the object is: setupLightkitButton
i all ready try this:


the only way I found was by edit the UI

You should never use a module’s widget class from another module. See Scripting and module development tutorial on the training page for details.

Instead, you can call methods implemented in the other module’s logic. In some experimental modules developers may work quick-and-dirty and put logic that could be useful for other modules in the widget. In this case you can either fix that module (move the useful code part into the module’s logic where you can access it from your own module) or just copy-paste the code into your module.

In this specific case, Lights module in Sandbox extension is implemented relatively cleanly: the function that is launched when setupLightKitButton is clicked (onSetupLighkit) calls the setLightkitInView function in the logic. So, in your module, you don’t need to deal with the Light module’s widget, just access its logic (or instantiate a new LightsLogic class) and use it.

thanks for the PowerPoint it gives me a better understanding.

1 Like