PDA

View Full Version : Why does QSound require a pointer?



BeautiCode
31st May 2015, 21:48
So I was experimenting with QSound...And after a while of trying to figure out why


QSound qs("st.wav");
qs.setLoops(1);
qs.play();

wouldn't work(didn't play audio), I discovered that


QSound* qs = new QSound("st.wav");
qs->setLoops(1);
qs->play();

worked. Why is this?

anda_skoa
31st May 2015, 21:55
It does not require to be allocated on the heap, but maybe in your stack allocated version you had a limited live time of that stack?
E.g. on a function's stack and the function ending/returning.


Cheers,
_

BeautiCode
1st June 2015, 00:35
Oh actually yeah I think that was the problem. Thanks.