Skip navigation.
Home
The QNX Community Portal

View topic - Assign names to widgets dynamically

Assign names to widgets dynamically

Isn't the name clear?

Assign names to widgets dynamically

Postby pradeep » Mon May 14, 2012 5:23 am

Dear all,

I am working on GUI which requires buttons ,labels and indicators, each 48 numbers respectively. I have created them using for loop ,i have looped for 48 times for each widget. This was succesfull and all the widgets were displayed on the screen as required.

but in the callbacks of i need to set resources to these widgets, i could not find a way to do this since i need to point to specific widget ,i tried using the arrayi.e,Ptwidget_t array[48] and assigned widget names to this array but it is showing unsupported declaration.

Can anyone suggest me a method to do this
pradeep
Active Member
 
Posts: 20
Joined: Tue Aug 09, 2011 7:17 am

Re: Assign names to widgets dynamically

Postby maschoen » Mon May 14, 2012 5:13 pm

If you are creating the widgets dynamically in code, you can save the widget pointer in an array.

PtWidget_t *widgets[NUMBER_WIDGETS];

for(i=0;...)
{
widgets[i] = PtCreateWidget(.....);
}


If you create the widgets in PhAB and you want to put the widget pointers in an array, you can't do it statically.

This doesn't work:

PtWidget_t *widgets[] =
{
ABW_widget_1,
ABW_widget_2,
...
};

Instead, in the setup function of the windows, put in some static code as follows:

int setup(...)
{
widgets[0] = ABW_widget_1;
widgets[1] = ABW_widget_2;
...
}
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Assign names to widgets dynamically

Postby pradeep » Tue May 15, 2012 7:13 am

Thaks maschoen for your reply,it helped me a lot now i have used below code


PtWidget_t *widgets[NUMBER_WIDGETS];

for(i=0;...)
{
widgets[i] = PtCreateWidget(.....);
}

now my code is working properly and i am able to realize widgets and also handle callbacks effectively.


regards
Pradeep
pradeep
Active Member
 
Posts: 20
Joined: Tue Aug 09, 2011 7:17 am


Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron