PDA

View Full Version : [closed] How to fill QList with struct data more elegant



KeineAhnung
8th May 2014, 08:49
Hi,

I have a QList with a custom data type. All I found on filling the list looked like this:

customStruct newStruct;
newStruct.prperty1 = xy;
newStruct.prperty2 = xy;
newStruct.prperty3 = xy;
[...]
newStruct.prpertyN = xy;
list.append(newStruct);
Is there a more elegant way to do that? So that everything is on one line or maybe two? Or does one line only work if I create a new class?

anda_skoa
8th May 2014, 09:21
You can add a constructor to customStruct to that you can write



list.append(customStruct(......));


Cheers,
_

KeineAhnung
8th May 2014, 09:28
Okay, I thought I had tried that...
Never the less I already switched to a class. Maybe I will add a signal as well.