Hi
How I Can Create Array of Widgets (For Example: QLineEdit) on Qt4?
Please Help Me!
Thanks.
Hi
How I Can Create Array of Widgets (For Example: QLineEdit) on Qt4?
Please Help Me!
Thanks.
MaybeQt Code:
QList<QLineEdit*> myList;To copy to clipboard, switch view to plain text mode
depends on what you want to do.
Lykurg
Is this bad? I want to create an array of widgets to put on a QStackedWidget. Can I do this:
Qt Code:
// ...in myfile.cpp... for(int a=0; a<2; a++) { myStack->addWidget(pb[a]); }To copy to clipboard, switch view to plain text mode
It compiles and seems to work. Previously when I've needed an array of Widgets, I would declare
QPushButton *pb[2];
in the header file. But is there any reason I cannot declare it in the .cpp file like above?
follow-up: if I need to replace the "2" with "getNumber()" like so:
Qt Code:
// ...in myfile.cpp... // QPushButton *pb[2]; // or // const int tempNum = getNumber(); // QPushButton *pb[tempNum]; for(int a=0; a<2; a++) { myStack->addWidget(pb[a]); }To copy to clipboard, switch view to plain text mode
I get an error: expected constant expression. Is there a way around this?
vonCZ (27th April 2009)
Bookmarks