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?
QtWS25 Last Chance

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 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?

    Pablo J. RoginaP 1 Reply Last reply
    0
    • D define-qt

      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?

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on 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
      0
      • D Offline
        D Offline
        define-qt
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • Pablo J. RoginaP Pablo J. Rogina

          @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 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 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 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 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
                0
                • K Konstantin Tokarev

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

                  D Offline
                  D Offline
                  define-qt
                  wrote on 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
                  0
                  • D define-qt

                    @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 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

                    • Login

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