PDA

View Full Version : How to declare QRadioButton number dynamically



BigHeadSammy
26th August 2016, 08:14
Hi

As title says, this is my code

...
QStringList test;
...
QRadioButton *Btn[test.size()];

but it show error "it needs constants"

i don't want to rewrite like this QRadioButton *Btn[100];

please give me some advice

thanks!

anda_skoa
26th August 2016, 11:55
When you declare an array on the stack, then the compiler needs to know the size at compile time.

You can either allocate an array on the heap (as that happens during runtime) or do the smart thing and use a container, e.g. QVector.

Cheers,
_