Important: Please read the Qt Code of Conduct -


  • I want a piece of music to be played as my application begins and till its can i do that ??

  • i know how to do it in qml.....not in qt c++...

    here goes...

    use a Timer....where onTrigger of that state(in Qml) the music starts playing...and when closing the app...u dont have to stop the music there because when u kill the application...everything shuts down.

    1.) use an import called
    import QtMultimediaKit 1.1

    2.) then.....
    add the sound file to your project folder ie. in the qml folder(urproject/qml/sounds/)....
    then use that in your application...
    by using this code....


    3.) then use a timer to make that file work in your app...

    4.) then use another timer on clicked function(if u require) to call the file to play....
    @Timer {
    interval: 1000;
    running: false;
    onTriggered: {
    rect.state = "menu"; /* play the file after it comes to this state!! */
    soundtimer.running = true;

    dont forget to give ids to the timers u create or any object/item that you create....because it will be easier for you to use them else where in your code.

  • I disagree that using a Timer is a good solution to replaying a sound file. You may have a delay of up to a full second.

    Just use:
    @ Audio { source: "mymusic.mp3"; playing: true; onStopped: play(); }@

  • i tried both guyz...
    but it says "QtMultimediakit" not installed...
    how to fix this now

  • Firstly, ensure you have specified
    @import QtMultimediaKit 1.1@

    That is, capital Q, capital M, capital K.

    Second, for some platforms, in your .pro I believe you require:

  • yep...i treid that still says "QtMultimediaKit" not installed :(

  • You should install QtMobility manually. I tried a couple of times for QtMobility. It does not automatically get installed by SDK. Compile QtMobility and install into the Qt base directory.
    This will solve your problem.

Log in to reply