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. QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior
QtWS25 Last Chance

QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 924 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.
  • H Offline
    H Offline
    hbatalha
    wrote on last edited by
    #1

    I have a function that is supposed to open a local media file.

    in that I only have one line of code (below):

    QDesktopServices::openUrl(QUrl::fromLocalFile("D:\\Desktop\\Test1\\ACID Explained - Atomic, Consistent, Isolated & Durable.mkv"));
    

    When I call that function through a pushButton click for the first time after I open the app it works fine but from the second time on it stops working. I call it many times after the first time but only works randomly.

    I am on Windows in MingW environment and I experienced this behavior with Qt 5.15.2, 6.1.2, 6.1.3 and 6.2.0.

    Has anyone experienced something similar?

    JonBJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which application opens that file ?
      Do you stop it between two calls ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply
      0
      • M Offline
        M Offline
        mchinand
        wrote on last edited by
        #3

        In addition to @SGaist 's questions, what is the behavior when you double-click on the file in Windows File Explorer and then when you double-click on the file subsequent times?

        H 1 Reply Last reply
        0
        • H hbatalha

          I have a function that is supposed to open a local media file.

          in that I only have one line of code (below):

          QDesktopServices::openUrl(QUrl::fromLocalFile("D:\\Desktop\\Test1\\ACID Explained - Atomic, Consistent, Isolated & Durable.mkv"));
          

          When I call that function through a pushButton click for the first time after I open the app it works fine but from the second time on it stops working. I call it many times after the first time but only works randomly.

          I am on Windows in MingW environment and I experienced this behavior with Qt 5.15.2, 6.1.2, 6.1.3 and 6.2.0.

          Has anyone experienced something similar?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @hbatalha said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

          I call it many times after the first time but only works randomly.

          Sounds like Windows application behaviour on the app associated with .mkv, not to do with Qt. Is it possible that does nothing if that file/URL is already open? Check running processes to see if that app might already be running on that file?

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Which application opens that file ?
            Do you stop it between two calls ?

            H Offline
            H Offline
            hbatalha
            wrote on last edited by
            #5

            @SGaist said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

            Which application opens that file ?

            Qt Widgets Application

            Do you stop it between two calls ?

            No

            SGaistS 1 Reply Last reply
            0
            • M mchinand

              In addition to @SGaist 's questions, what is the behavior when you double-click on the file in Windows File Explorer and then when you double-click on the file subsequent times?

              H Offline
              H Offline
              hbatalha
              wrote on last edited by
              #6

              @mchinand said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

              In addition to @SGaist 's questions, what is the behavior when you double-click on the file in Windows File Explorer and then when you double-click on the file subsequent times?

              It opens files normally as expected

              M 1 Reply Last reply
              0
              • H hbatalha

                @mchinand said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

                In addition to @SGaist 's questions, what is the behavior when you double-click on the file in Windows File Explorer and then when you double-click on the file subsequent times?

                It opens files normally as expected

                M Offline
                M Offline
                mchinand
                wrote on last edited by
                #7

                @hbatalha said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

                It opens files normally as expected

                What is the behavior when you click on the same file a second time when the application is still running from clicking on the file the first time?

                H 1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hbatalha
                  wrote on last edited by
                  #8

                  @JonB said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

                  Sounds like Windows application behaviour on the app associated with .mkv, not to do with Qt.

                  It looks like you are right, I just switched the default app for .mkv from VLC to Windows Movies & TV and it is opening file every time I call the function.

                  Check running processes to see if that app might already be running on that file?

                  No, no process is running on the file.

                  1 Reply Last reply
                  0
                  • M mchinand

                    @hbatalha said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

                    It opens files normally as expected

                    What is the behavior when you click on the same file a second time when the application is still running from clicking on the file the first time?

                    H Offline
                    H Offline
                    hbatalha
                    wrote on last edited by
                    #9

                    @mchinand said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

                    @hbatalha said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

                    It opens files normally as expected

                    What is the behavior when you click on the same file a second time when the application is still running from clicking on the file the first time?

                    It restarts the media.

                    1 Reply Last reply
                    0
                    • H hbatalha

                      @SGaist said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

                      Which application opens that file ?

                      Qt Widgets Application

                      Do you stop it between two calls ?

                      No

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @hbatalha said in QDesktopServices::openUrl(QUrl::fromLocalFile()) strange behavior:

                      Qt Widgets Application

                      Is it your own application ?
                      If so, I would say that it does not handle opening the file properly ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        hbatalha
                        wrote on last edited by
                        #11

                        Update: I really think @JonB is right, it's was a Windows behavior rather than Qt's. After switching back to VLC as the default app for .mkv, calling the function opens file every time.

                        1 Reply Last reply
                        1

                        • Login

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