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. Recognizing URL while typing
QtWS25 Last Chance

Recognizing URL while typing

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 659 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.
  • O Offline
    O Offline
    oneeyeman1
    wrote on last edited by
    #1

    Hi, ALL,
    Have following issue.

    Most editors I know can do following:

    When I type www.google.com and press "Space Bar> the editor will successfully recognize that text as URL and correctly render it as such.
    If I do copy and paste the text that contains such a text, again, the editor will successfully recognize it and render it as such.

    However, it looks like this is not the case with QTextEdit control.

    With this control it looks like I should enter <a href=....... /a> it order for the text to be rendered as URL.

    Keep in mind - I am not talking here about click processing - strict rendering.

    Is there any styles, or maybe signal I shuold catch in order to render URL properly inside QTextEdit?

    And I am not interested in QBrowserEdit. From my google search it looks like this control is for read-only text, which is NOT the case.

    Thank you.

    O 1 Reply Last reply
    0
    • A Offline
      A Offline
      arsinte_andrei
      wrote on last edited by
      #2

      Can you offer more details about what you want to achieve and about your project? also about Qt version and Os? Do you try to do your own web browser?

      O 1 Reply Last reply
      2
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        you would most likely need to scan the current input on every keypress, do pattern matching against what was typed, and identify the patterns that look like URLs. I personally dislike URL identification when I'm typing something in a document or editor. Id rather manually mark it as such afterwards. Very annoying when I type @ and it automatically tries to turn it into a mailto: URL.

        1 Reply Last reply
        5
        • A arsinte_andrei

          Can you offer more details about what you want to achieve and about your project? also about Qt version and Os? Do you try to do your own web browser?

          O Offline
          O Offline
          oneeyeman1
          wrote on last edited by
          #4

          Hi,
          @arsinte_andrei said in Recognizing URL while typing:

          Can you offer more details about what you want to achieve and about your project? also about Qt version and Os? Do you try to do your own web browser?

          Just look at my OP.
          I didn't have to write the whole HTML, and the link is rendered as it should.
          Or try to do it yourself - when you start replying, try to type "www.google.com" and see how that text will be changed.
          Don't click on the link - just see how it will be rendered (blue text).

          My Qt version is 5.7.1 on Gentoo Linux.

          No, not web browser. I specifically said "QTextEdit", right?

          Thank you.

          1 Reply Last reply
          0
          • Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            If you just want it to be blue you can use a QSyntaxHighlighter - also take a look at the example

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            4
            • O oneeyeman1

              Hi, ALL,
              Have following issue.

              Most editors I know can do following:

              When I type www.google.com and press "Space Bar> the editor will successfully recognize that text as URL and correctly render it as such.
              If I do copy and paste the text that contains such a text, again, the editor will successfully recognize it and render it as such.

              However, it looks like this is not the case with QTextEdit control.

              With this control it looks like I should enter <a href=....... /a> it order for the text to be rendered as URL.

              Keep in mind - I am not talking here about click processing - strict rendering.

              Is there any styles, or maybe signal I shuold catch in order to render URL properly inside QTextEdit?

              And I am not interested in QBrowserEdit. From my google search it looks like this control is for read-only text, which is NOT the case.

              Thank you.

              O Offline
              O Offline
              oneeyeman1
              wrote on last edited by
              #6

              @oneeyeman1

              I'm basically looking for something like this

              1 Reply Last reply
              0
              • Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                I'm not aware that there is a out-of-the-box solution for Qt for this - you have to do it on your own but the QSyntaxHighlighter example is a good starting point.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                2

                • Login

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