Results 1 to 3 of 3

Thread: Why does QSound require a pointer?

  1. #1
    Join Date
    Mar 2015
    Posts
    24
    Qt products
    Qt5
    Platforms
    Windows

    Default Why does QSound require a pointer?

    So I was experimenting with QSound...And after a while of trying to figure out why
    Qt Code:
    1. QSound qs("st.wav");
    2. qs.setLoops(1);
    3. qs.play();
    To copy to clipboard, switch view to plain text mode 
    wouldn't work(didn't play audio), I discovered that
    Qt Code:
    1. QSound* qs = new QSound("st.wav");
    2. qs->setLoops(1);
    3. qs->play();
    To copy to clipboard, switch view to plain text mode 
    worked. Why is this?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Why does QSound require a pointer?

    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,
    _

  3. #3
    Join Date
    Mar 2015
    Posts
    24
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Why does QSound require a pointer?

    Oh actually yeah I think that was the problem. Thanks.

Similar Threads

  1. Replies: 9
    Last Post: 17th February 2014, 04:09
  2. Replies: 2
    Last Post: 10th December 2013, 19:58
  3. Qt 4.8.1 + OpenCv - Why does release app require QtTest4.dll
    By airproject in forum Installation and Deployment
    Replies: 0
    Last Post: 10th February 2013, 17:12
  4. Wht packages(Ex:GCC,....) do we require to install qt sdk?
    By qtlinuxnewbie in forum Installation and Deployment
    Replies: 3
    Last Post: 27th September 2010, 06:36
  5. Why do I require a new event loop from a GUI?
    By pitonyak in forum Qt Programming
    Replies: 5
    Last Post: 17th February 2010, 07:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.