Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QUrl::fromLocalFile and relative path

QUrl::fromLocalFile and relative path

Scheduled Pinned Locked Moved General and Desktop
11 Posts 5 Posters 23.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sierdzio
    Moderators
    wrote on 26 Jan 2013, 15:32 last edited by
    #2

    @
    QUrl::fromLocalFile(QFile(yourRelativePath).absoluteFilePath());
    @

    (Z(:^

    1 Reply Last reply
    0
    • P Offline
      P Offline
      patouf35
      wrote on 26 Jan 2013, 19:25 last edited by
      #3

      Thanks! It all worked perfectly fine! :)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        syfy323
        wrote on 17 Nov 2013, 17:30 last edited by
        #4

        How can I do this on Qt 5.2?
        There is no such function.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 17 Nov 2013, 17:33 last edited by
          #5

          I think it has been moved to QFileInfo. Which makes sense, to be honest ;)

          (Z(:^

          1 Reply Last reply
          0
          • S Offline
            S Offline
            syfy323
            wrote on 17 Nov 2013, 21:19 last edited by
            #6

            [quote author="sierdzio" date="1384709587"]I think it has been moved to QFileInfo. Which makes sense, to be honest ;)[/quote]

            This works well, thank you!

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AedisToru
              wrote on 10 Jul 2014, 20:26 last edited by
              #7

              @ QMediaContent menu(QUrl::fromLocalFile(QFileInfo("Menu.wav").absoluteFilePath()));
              player->setMedia(menu);
              player->play();@

              This works fine for me in Qt5.2.
              The sound is played as long as I start the application via Qt. However if I try to open the exe in the build folder my program runs, but without the sound. I included all dll files that the exe file asked for.

              I already tried to put the wav file in a different folder than the build folder, but I couldn't get the sound to work anywhere.

              Any suggestions?

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andreyc
                wrote on 10 Jul 2014, 20:30 last edited by
                #8

                Are there any messages if you start your app in a console ?

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  AedisToru
                  wrote on 10 Jul 2014, 20:33 last edited by
                  #9

                  [quote author="andreyc" date="1405024207"]Are there any messages if you start your app in a console ?[/quote]

                  yes, there is:

                  defaultServiceProvider::requestService(): no service found for -"org.qt-project.qt.mediaplayer"

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andreyc
                    wrote on 10 Jul 2014, 20:46 last edited by
                    #10

                    You need to make sure that mediaservice plugins are available for your application.

                    I guess it should be in the PATH if you run your app on the same machine where Qt is installed or you must deploy your app and all necessary libraries if a machine does not have Qt installed.
                    See "Deploying Qt Applications":http://qt-project.org/doc/qt-5/deployment.html
                    If you run it on Windows that there is nice wiki page page about "Deploy an Application on Windows":http://qt-project.org/wiki/Deploy_an_Application_on_Windows

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      AedisToru
                      wrote on 10 Jul 2014, 21:13 last edited by
                      #11

                      Thanks so much!

                      Your guide really helped!

                      I noticed that I had copied the wrong dll files when I used the windows search.
                      Now that I have the correct ones sound plays as it should!

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved