in GUI Development by


I want to create PushBottons after get data from device, but I try "var WidgetSet::PushButton btn = new WidgetSet::PushButton" in SlotMethod, it will be created but not show in screen (I can read and write button label's attribute), how to show it in Screen?



1 Answer

0 votes

Hello YuChing,

actually you create only a new instance of the class WidgetSet::PushButton. Thereupon you need two additional steps:

Step 2. Configure the button.

In particular you should set the property Appearance of the just created button instance to refer to one of available PushButtonConfig objects. Otherwise the button will not have any information how to appear. You will see nothing.

Step 3. Add the button instance to an existing GUI component.

In order to be visible on the screen, every view (thus also a button) has to belong to the view tree. This can be controlled by using the methods Add() and Remove() of the GUI component in context of which you want the button to be added or later removed again. Please see the section: Compose the component programmatically.

Accoringly the correct code to create and show a button would be:

// Step 1: Create a new instance of the button
var WidgetSet::PushButton btn = new WidgetSet::PushButton;

// Step 2: Configure the button instance
btn.Appearance = WidgetSet::PushButton_Medium;
btn.Label      = "Hello World!";

// Step 3: Add it to the view tree. Assuming this code is executed in
// context of an already visible GUI component
Add( btn, 0 );

// ... or if you want the button to be added to 'other' component
otherComponent.Add( btn, 0 );

I hope it helps you further.

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint