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. How to get the original string from QUrl?
Forum Updated to NodeBB v4.3 + New Features

How to get the original string from QUrl?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 4.7k Views 1 Watching
  • 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.
  • L Offline
    L Offline
    lvshuchengyin
    wrote on last edited by
    #1

    @
    href="myself.pro://account=tmp@tmp.com&type=info";
    QUrl url(href);
    @

    That is not a valid url in QUrl. But I have to get that From QUrl.
    How could I get the href again?

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      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.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lvshuchengyin
        wrote on last edited by
        #3

        Thank you again. :)

        Actually, I use QWebView. It access to a website. That website have some a link. Whick href is "myself.pro://account=tmp@tmp.com&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?

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          i see...
          does "QUrl::toString()":http://qt-project.org/doc/qt-4.8/qurl.html#toString work for you?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lvshuchengyin
            wrote on last edited by
            #5

            @QUrl::toString() @
            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]

            1 Reply Last reply
            0
            • mranger90M Offline
              mranger90M Offline
              mranger90
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0

              • Login

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