How accessing a member of a Widget in a QList?
Hi,
I have created a new widget and called it MyWidget (it includes some qcomboboxes and some qlabels); then I have created a QList like this:
Code:
QList<QWidget *> myList;
and appended 2 myWidget:
Code:
myWidget_1 = new MyWidget;
myWidget_2 = new MyWidget;
myList.append(myWidget_1);
myList.append(myWidget_2);
Now, how can i access a combobox in one of myWidget? The following code gives error during compilation (error: ‘class QWidget’ has no member named ‘comboBox’):
Code:
int index = myList.at(0)->comboBox->currentIndex();
Regards
Re: How accessing a member of a Widget in a QList?
As the error message states, QWidget has no such member. You should store MyWidget pointers if you want to access MyWidget members:
Code:
QList<MyWidget*> myList;
PS. You should try to avoid public variables ;)
Re: How accessing a member of a Widget in a QList?
Thank's jpn,
now works.
Bye