View topic - Assign names to widgets dynamically
Assign names to widgets dynamically
3 posts
• Page 1 of 1
Assign names to widgets dynamically
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
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
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;
...
}
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: 2715
- Joined: Wed Jun 25, 2003 5:18 pm
Re: Assign names to widgets dynamically
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
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
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest