Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Override link QUrl parsing?

Override link QUrl parsing?

Scheduled Pinned Locked Moved Solved Qt WebKit
qurlqt 4.8qwebpage
9 Posts 3 Posters 2.7k 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.
  • D Offline
    D Offline
    define-qt
    wrote on 13 Jun 2018, 07:58 last edited by
    #1

    Hello, I'm using Qt 4.8.7. My application needs to handle web pages with "invalid" URLs. It handles these URLs specially; for example I've already overridden QNetworkAccessManager::createRequest.

    The problem is making clickable links work; the HTML <a> tags appear to function at first, but the QUrl returned by linkClicked() is empty. My code works fine with valid URL's but I can't figure out a way to force linkClicked() to return a URL that it doesn't think is valid.

    Is there a way around this?

    P 1 Reply Last reply 13 Jun 2018, 16:42
    0
    • D define-qt
      13 Jun 2018, 07:58

      Hello, I'm using Qt 4.8.7. My application needs to handle web pages with "invalid" URLs. It handles these URLs specially; for example I've already overridden QNetworkAccessManager::createRequest.

      The problem is making clickable links work; the HTML <a> tags appear to function at first, but the QUrl returned by linkClicked() is empty. My code works fine with valid URL's but I can't figure out a way to force linkClicked() to return a URL that it doesn't think is valid.

      Is there a way around this?

      P Offline
      P Offline
      Pablo J. Rogina
      wrote on 13 Jun 2018, 16:42 last edited by
      #2

      @define-qt said in Override link QUrl parsing?:

      linkClicked

      spoiler alert: not that I have work with it...

      have you messed around with linkDelegationPolicy as the linkClicked() documentation refers to?

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      D 1 Reply Last reply 13 Jun 2018, 20:09
      0
      • D Offline
        D Offline
        define-qt
        wrote on 13 Jun 2018, 19:41 last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • P Pablo J. Rogina
          13 Jun 2018, 16:42

          @define-qt said in Override link QUrl parsing?:

          linkClicked

          spoiler alert: not that I have work with it...

          have you messed around with linkDelegationPolicy as the linkClicked() documentation refers to?

          D Offline
          D Offline
          define-qt
          wrote on 13 Jun 2018, 20:09 last edited by
          #4

          @Pablo-J.-Rogina Yeah, I have it set to delegate all links, which causes it to emit linkClicked. Without that, it's not even clear to me how the links are handled. Unless there's a different way to do it by not delegating the links and overriding a different method?

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Konstantin Tokarev
            wrote on 14 Jun 2018, 14:56 last edited by
            #5

            What kind of "invalid" URLs do you have? If they contain some random text, your only solution is to handle clicks via JS and do processing there.

            1 Reply Last reply
            1
            • D Offline
              D Offline
              define-qt
              wrote on 15 Jun 2018, 01:11 last edited by
              #6

              I solved my problem, in that I had neglected to encode some characters that needed to be, so they actually were valid after all. User error.

              I never did find a solution for parsing truly invalid URL's.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                Konstantin Tokarev
                wrote on 18 Jun 2018, 11:51 last edited by
                #7

                As I said above, you can parse truly invalid URLs via custom onclick handler of element

                D 1 Reply Last reply 20 Jun 2018, 07:08
                0
                • K Konstantin Tokarev
                  18 Jun 2018, 11:51

                  As I said above, you can parse truly invalid URLs via custom onclick handler of element

                  D Offline
                  D Offline
                  define-qt
                  wrote on 20 Jun 2018, 07:08 last edited by
                  #8

                  @Konstantin-Tokarev Sorry, I wasn't ignoring your post. I'm sure that would work, but JS wasn't an option for this particular application.

                  K 1 Reply Last reply 20 Jun 2018, 11:33
                  0
                  • D define-qt
                    20 Jun 2018, 07:08

                    @Konstantin-Tokarev Sorry, I wasn't ignoring your post. I'm sure that would work, but JS wasn't an option for this particular application.

                    K Offline
                    K Offline
                    Konstantin Tokarev
                    wrote on 20 Jun 2018, 11:33 last edited by
                    #9

                    JS handler can be added via evaluateJavaScript, and Qt bridge used to provide actual handling via exported QObject

                    I've considered adding API for C++ event hadlers, but that would require some development effort

                    1 Reply Last reply
                    1

                    3/9

                    13 Jun 2018, 19:41

                    topic:navigator.unread, 6
                    • Login

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