How to get the original string from QUrl?
That is not a valid url in QUrl. But I have to get that From QUrl.
How could I get the href again?
i am not sure what you mean exactly. but i think you mean when you create an invalid QUrl object from a string and pass that object on and want the string which was used for creation off that QUrl object?
Can't you jsut pass the QString and create QUrl object everytime you need it.
Note that it is also possible to just pass the string to a Qt method which expects a QUrl. Qt (actually the compiler) converts it implicitly to a QUrl then.
Thank you again. :)
Actually, I use QWebView. It access to a website. That website have some a link. Whick href is "myself.pro://firstname.lastname@example.org&type=info".
I reimplement the QWebPage and rewrite the acceptNavigationRequest(QWebFrame * frame, const QNetworkRequest & request, NavigationType type).
So I get the url by use request.url(), but I can get the href, because that is not a valid url string.
I can see the original href by use request.url().errorString(). It contains the href , but I have to parse the string.
Does have another method?
does "QUrl::toString()":http://qt-project.org/doc/qt-4.8/qurl.html#toString work for you?
It return empty string.
[quote author="raven-worx" date="1387540694"]i see...
does "QUrl::toString()":http://qt-project.org/doc/qt-4.8/qurl.html#toString work for you?[/quote]
I think that what raven-worx meant was that you call toString() on your URL variable, i.,e. url.toString(QUrl:XXXXX) , where the XXXXX is the particular formatting option. If that fails to give you exactly what you need, you might want to consider a QRegExp, regular expression, to parse the url string.