Override link QUrl parsing?
-
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?
-
@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?
-
@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?
-
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.
-
As I said above, you can parse truly invalid URLs via custom
onclick
handler of element -
@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.
-
JS handler can be added via
evaluateJavaScript
, and Qt bridge used to provide actual handling via exported QObjectI've considered adding API for C++ event hadlers, but that would require some development effort