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 link in default browser from Qtextbrowser

Open link in default browser from Qtextbrowser

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 12.3k Views 1 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
    Mashpy
    wrote on last edited by
    #1

    I search google to find this solution. but i was confused how to solve this problem.

    In MainWindow.ui i drag & drop QTextBrowser. here i put someText where there is hyperlink. After compliling this application when i click this link this is not working.

    I want it will open in my default browser like as firefox.

    can u help me how to solve this problem?

    is it something like -

    @ui->textBrowser->openExternalLinks(default);@

    but this code does not work.

    1 Reply Last reply
    0
    • ZlatomirZ Offline
      ZlatomirZ Offline
      Zlatomir
      wrote on last edited by
      #2

      Please tell us how it doesn't work: it gives you a compile error or how exactly isn't working, is default of type bool, because that function takes a bool parameter, if it is a bool make sure it's true when you call the function, or use: ui->textBrowser->setOpenExternalLinks(true); see the documentation "here":http://qt-project.org/doc/qt-4.8/qtextbrowser.html#openExternalLinks-prop

      https://forum.qt.io/category/41/romanian

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

        i have set
        @ui->textBrowser->setOpenExternalLinks(true); @

        but not working.
        there is no complile error. but when i click on the application hipertext link, it does not woking.

        1 Reply Last reply
        0
        • ZlatomirZ Offline
          ZlatomirZ Offline
          Zlatomir
          wrote on last edited by
          #4

          Check this, and see if it works:
          @#include <QApplication>
          #include <QTextBrowser>

          int main(int argc, char** argv)
          {
          QApplication a(argc, argv);
          QTextBrowser tb;

          tb.setOpenExternalLinks(true);
          tb.setText("Link to <a >google.com</a> ... more text");
          
          tb.show();
          return a.exec(&#41;;
          

          }@

          https://forum.qt.io/category/41/romanian

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            you need to set the text with QTextBrowser::setHtml() in order to open links.
            Also links must be specified in a valid HTML syntax.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • ZlatomirZ Offline
              ZlatomirZ Offline
              Zlatomir
              wrote on last edited by
              #6

              raven-wrox, for me the setText works, but the a href should be properly formatted and the forum software seems to mess-up the format of the a href.
              -second try:- not working, see example "here":http://www.w3schools.com/tags/att_a_href.asp

              https://forum.qt.io/category/41/romanian

              1 Reply Last reply
              0
              • raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #7

                [quote author="Zlatomir" date="1367075376"]the forum software seems to mess-up the format of the a href [/quote]
                yea i thought so... i just wanted to mention that... so he doesn't copy-and-paste it and reports back that it's not working.

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                0
                • ZlatomirZ Offline
                  ZlatomirZ Offline
                  Zlatomir
                  wrote on last edited by
                  #8

                  [quote author="raven-worx" date="1367075504"]
                  yea i thought so... i just wanted to mention that... so he doesn't copy-and-paste it and reports back that it's not working.
                  [/quote]
                  I forgot to add a thank you, because i didn't notice that until after i read your post.

                  https://forum.qt.io/category/41/romanian

                  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