PDA

View Full Version : Signal with pointer passes only the first value



Basti300
14th September 2010, 13:09
Hey People

As the Caption already meantions is my problem that i send a signal from one widget to another one passing 3 pointers to arrays. but in the slot i get only the first value af each array.
That means in detail:

i have a widget that has for example:

double* freq = new double[10000];
float* re = new float[10000];
float* im = new float[10000];

i create a SIGNAL that looks like this:

void speccdata_send(double*, float*, float*);

and i emit it like this:

emit speccdata_send(freq, re, im);

the pointer seems to "arrive" at the SLOT too but only the first value of the 3 arrays is correct the rest is 0 .
Does anyone have an idea what my mistake is?

Thanks
Basti

wysota
14th September 2010, 13:27
I suspect you are using threads, right?

By the way, why don't you use QVector or QList instead of those C-arrays?

Zlatomir
14th September 2010, 13:37
You better follow Wysota's advices,

And when you work with c-style arrays you are more secure if you send the size too, not let the receiver slot (which may be modified by someone else in the future) guess that the size didn't change (and if you pass the sizes, you avoid the use "magic numbers" for the size of arrays)