View Single Post
pichlo's Avatar
Posts: 6,450 | Thanked: 20,983 times | Joined on Sep 2012 @ UK
#8
@Copernicus,
Thanks, that is a nice way to do it but I have already refactored it even further. As I have quite a bunch of combo boxes that change contents each time one of the other combos change, I thought it made sense to write a single function:
Code:
static void refillComboBox (QComboBox *combo,
                            const QString items[],
                            int number_of_items,
                            int selected_item);
and call it like this:
Code:
#define ITEMS(x)  sizeof x / sizeof x[0]

static const QString foo[] = { "Hz", "kHz" };
refillComboBox(ui.comboBlaBlaBla, foo, ITEMS(foo), 0 };

static const QString bar[] = { micro + "s", "ms", "s" };
refillComboBox(ui.comboBlaBlaBla, bar, ITEMS(bar), 3 };
...etc.

@Halftux,
I happen to agree with Copernicus. A cute way of (ab)using an enum but I would not go there.

@pali,
Of course I am using -march=armv7-a. That is the CFAGS trick mentioned in the OP. Without it, nothing works.
 

The Following 2 Users Say Thank You to pichlo For This Useful Post: