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. Open an HTML file in Internet Explorer

Open an HTML file in Internet Explorer

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 4.1k 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.
  • M Offline
    M Offline
    MSDQuick
    wrote on last edited by
    #1

    Hi guys;
    When the user presses a button, I would like to open an HTML file in Internet Explorer.
    I tried to use these codes, but it doesn't work:

    void MainWindow::on_pushButton_clicked()
    {
        QDesktopServices::openUrl(QUrl(":/Images/Help.html", QUrl::TolerantMode));
    }
    
    

    Thanks for helping.
    MSD.

    1 Reply Last reply
    0
    • JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @MSDQuick said in Open an HTML file in Internet Explorer:

      but it doesn't work

      And what does happen then?

      Anyway, is something like https://stackoverflow.com/questions/37898660/qdesktopservicesopenurl-does-not-work-neither-for-urls-nor-for-local-files-o relevant to your situation? There are several other Google hits for QDesktopServices::openUrl, are they relevant?

      M 1 Reply Last reply
      0
      • JonBJ JonB

        @MSDQuick said in Open an HTML file in Internet Explorer:

        but it doesn't work

        And what does happen then?

        Anyway, is something like https://stackoverflow.com/questions/37898660/qdesktopservicesopenurl-does-not-work-neither-for-urls-nor-for-local-files-o relevant to your situation? There are several other Google hits for QDesktopServices::openUrl, are they relevant?

        M Offline
        M Offline
        MSDQuick
        wrote on last edited by
        #3

        @JNBarchan
        It does any thing.
        I changed the code to this:

        QDesktopServices::openUrl(QUrl::fromUserInput("Help.html","/Images/"));
        

        Now it opens a web browser and puts "Help.html" in address bar and shows error opening page.
        0_1506078462706_Capture.JPG

        My HTML is located in my application resources directory, and I think it can not find that address.

        1 Reply Last reply
        0
        • JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          Then I presume you need to specify a (more) absolute URL. Have you tried /Help.html or something like http://localhost/Help.html? Have you tried opening the file in IE and copying the page's URL back into your source code? I don't even know whether you are servicing these web pages via an HTTP server or just via direct file access...?

          M 1 Reply Last reply
          1
          • JonBJ JonB

            Then I presume you need to specify a (more) absolute URL. Have you tried /Help.html or something like http://localhost/Help.html? Have you tried opening the file in IE and copying the page's URL back into your source code? I don't even know whether you are servicing these web pages via an HTTP server or just via direct file access...?

            M Offline
            M Offline
            MSDQuick
            wrote on last edited by
            #5

            @JNBarchan

            What I need is :
            I created a Help file (as a HTML file) about my application, and I put it in my "resources" directory. Now I want to open that file when I press a button in my application. That's all.

            Thanks.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Paul Thompson
              wrote on last edited by
              #6

              You may have better luck if you deploy the file to your application path (or a subdirectory thereof) and then open the URL:

              QDesktopServices::openUrl(QUrl("file:///" + QCoreApplication::applicationDirPath() + "/help.html"));
              
              M 1 Reply Last reply
              2
              • P Paul Thompson

                You may have better luck if you deploy the file to your application path (or a subdirectory thereof) and then open the URL:

                QDesktopServices::openUrl(QUrl("file:///" + QCoreApplication::applicationDirPath() + "/help.html"));
                
                M Offline
                M Offline
                MSDQuick
                wrote on last edited by
                #7

                @Paul-Thompson
                Good idea,
                Problem solved, thanks.

                P 1 Reply Last reply
                1
                • M MSDQuick

                  @Paul-Thompson
                  Good idea,
                  Problem solved, thanks.

                  P Offline
                  P Offline
                  Paul Thompson
                  wrote on last edited by
                  #8

                  @MSDQuick
                  You're welcome.

                  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