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(); MacOS Issues
Forum Updated to NodeBB v4.3 + New Features

QDesktopServices::openUrl(); MacOS Issues

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 684 Views 2 Watching
  • 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.
  • I Offline
    I Offline
    imikejackson
    wrote on last edited by
    #1

    We are using the code:

    QDesktopServices::openUrl(url);
    

    where url is "file:///Users/mjackson/Workspace1/DREAM3D-Build/NX-Commercial-Debug-Qt68-Vtk94/Bin/DREAM3DNX_d.app/Contents/Resources/Help/DREAM3DNX/html/Visualization/ApplyingRepresentations.html#outline-opacity"

    Note the anchor tag at the end of the URL. This seems to work fine on Windows and Linux, but on MacOS it seems to strip the trailing # anchor tag. I couldn't find anything definitive on the internet. I did paste the URL into the terminal and use the open command and it also strips the # tag from the URL.

    Does the QDesktopServices::openUrl() use this same feature? Does it use the 'open' command underneath the covers?

    We are using Qt 6.7/6.8/6.9 for our project.

    Thank You for any help.

    Mike Jackson mike.jackson@bluequartz.net
    BlueQuartz Software www.bluequartz.net

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kevin Hoang
      wrote on last edited by
      #2

      QDesktopServices::openUrl and the open command work the same, but the actual behavior depends on how the default browser handles web URLs or HTML files.

      I tried the command open https://en.wikipedia.org/wiki/URL_fragment#Examples on macOS and it worked just fine. I think the issue on your side might be that the default browser isn't handling the anchor tag properly on macOS.

      Try copying the URL and pasting it directly into the address bar of your default browser to see if the anchor works as expected.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        imikejackson
        wrote on last edited by
        #3

        Interesting that your provided URL actually works just fine with Safari, FireFox, Chrome, Brave, and Edge.

        Looks like the difference is with "file://" versus "https://". Trying my URL which is "file://" does not work with any of the browsers using the "open" command. So I'm assuming it wouldn't work with QDesktopServices either.

        Mike Jackson mike.jackson@bluequartz.net
        BlueQuartz Software www.bluequartz.net

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Kevin Hoang
          wrote on last edited by Kevin Hoang
          #4

          Ohhh, I see now, it's a macOS feature, where missing details are just part of the charm. Gotta keep the mystery alive for the Apple fans. 😄

          1 Reply Last reply
          0
          • I Offline
            I Offline
            imikejackson
            wrote on last edited by
            #5

            @Kevin-Hoang I was looking for some clarity if this is a Qt bug or if QDesktopServices just calls out to the 'open' command. Wasn't really looking for the completely non-helpful sarcasm. You-do-you but I don't typically let me feelings for a particular OS's issues play into my messages. When you get as old as I am they basically all suck. They all have their issues (charms as you would call it). None of that is helpful in this context. I need to figure out if I am barking up the wrong tree, if there is a known work around, or if nothing can be done except to file a bug with Apple.

            Mike Jackson mike.jackson@bluequartz.net
            BlueQuartz Software www.bluequartz.net

            JonBJ 1 Reply Last reply
            0
            • I imikejackson

              @Kevin-Hoang I was looking for some clarity if this is a Qt bug or if QDesktopServices just calls out to the 'open' command. Wasn't really looking for the completely non-helpful sarcasm. You-do-you but I don't typically let me feelings for a particular OS's issues play into my messages. When you get as old as I am they basically all suck. They all have their issues (charms as you would call it). None of that is helpful in this context. I need to figure out if I am barking up the wrong tree, if there is a known work around, or if nothing can be done except to file a bug with Apple.

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

              @imikejackson
              I think you were a little harsh on the poster's slightly light-hearted response, but never mind.

              Trusting you won't take this wrong, but if you do not get an answer here I would try taking a look at the Qt source for QDesktopServices to see what the MacOS code does presumably in the way of a "system" call if I wanted to understand its behaviour. I don't use MacOS, only Linux & Windows. I suspect just reporting a Qt code issue to Apple would not get you anywhere, they would want to know what system call is used. If you wait for someone else to give you a definitive answer here it might not be forthcoming, Just saying.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                Kevin Hoang
                wrote on last edited by
                #7

                @imikejackson I'm sorry! It was just a light-hearted comment — I think you might have taken it a bit too seriously. What I meant was that this is to be a macOS issue, not a Qt one.

                As for workarounds, you could try setting up a simple local server to serve your HTML with the anchor tag, or create a minimal setup using QWebViewer to handle it within your app, though both options are a bit more complex.

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  imikejackson
                  wrote on last edited by
                  #8

                  I don't think I was harsh at all. The joke is old and been run through time and time and time again. It is a meme at this point that "insert operating system" sucks/hides/screwed up "insert something here".

                  Looked at the Qt Source code and nothing helps there. That sends you to NSWorkspace::openURL function. Nothing special in the docs for that method either. Until you start getting really specific in Google which after a bit yields:

                  https://stackoverflow.com/questions/16223026/open-an-html-page-to-an-anchor-on-mac-os-from-command-line

                  Which then leads you to:

                  https://apple.stackexchange.com/questions/194501/open-a-file-url-with-anchor-from-terminal/197284#197284

                  which basically confirms that the code path that Qt is using is broken for Anchors on MacOS. I would blame Apple for this. Not that they are going to listen.

                  Now of course, since MacOS is just a meme at this point, doing osascript -e 'tell application "Safari" to open location "file:///Users/mjackson/Workspace1/DREAM3D-Build/NX-Commercial-Debug-Qt68-Vtk94/Bin/DREAM3DNX_d.app/Contents/Resources/Help/DREAM3DNX/html/Visualization/ApplyingRepresentations.html#outline-opacity"' does actually open the page + anchor but none of the images are rendered.

                  Chrome, Edge and Brave all do load the images.

                  What ever.

                  We spent a bunch of time creating docs that could be served without the need to include QWebView or a built in web server for security purposes. Our clients did not like having those services running, even on the loop-back address and a random port. So we are stuck with local files.

                  Mike Jackson mike.jackson@bluequartz.net
                  BlueQuartz Software www.bluequartz.net

                  1 Reply Last reply
                  0
                  • I imikejackson has marked this topic as solved on

                  • Login

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