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. QUrl grief
Forum Updated to NodeBB v4.3 + New Features

QUrl grief

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • D Offline
    D Offline
    DrProton
    wrote on last edited by
    #1

    I'm having some trouble with Qurls and QNetworkAccessManager::Get. Trouble is when I'm trying to get a complicated url like this: (ignore the spaces)

    "http://10.0.0.1:60152/liveview.JPG?% 211234% 21http% 2dget% 3a% 2a% 3aimage% 2fjpeg% 3a% 2a% 21% 21% 21% 21% 21"

    If I created the Qurl as:

    @QUrl MyUrl("http://10.0.0.1:60152/liveview.JPG?% 211234% 21http% 2dget% 3a% 2a% 3aimage% 2fjpeg% 3a% 2a% 21% 21% 21% 21% 21"); @

    When I use the get method qt changes all the % signs to % 25 so I'll get things like
    @.JPG?% 25211234% 2521http...@
    Which the server doesn't understand and the get fails.

    Using this code:

    @QByteArray urltemp=QUrl::toPercentEncoding(IncomingUrl.toUtf8());
    url=QUrl::fromEncoded(urltemp);
    ...->Get(url);@
    

    Seems to have a correctly formatted url but the reply returns QNetworkReply::ProtocolUnknownError (301). If I put a simple URL through the above code it still looks correct, but I get the same error. Removing the above code and directly getting a simple url works.

    How can I fix this error?

    Edit: I am trying to show the urls with precent encoding. How do I post something with (percent sign)(Hex code) and not have the forum post look all messed up? For now I just put a space after each percent sign.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stevenceuppens
      wrote on last edited by
      #2

      Hi,

      I should use QUrlQuery class

      @
      QUrl url("http://my-url");

      QUrlQuery query;
      query.addQueryItem("key","value");

      url.setQueryItem(query);
      @

      Or you can also use a lot of other useful methods of the QUrlQuery class to create you url with arguments...

      Steven CEUPPENS
      Developer / Architect
      Mobile: +32 479 65 93 10

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DrProton
        wrote on last edited by
        #3

        Found that sending ->Get the non percent encoded form works just fine.

        @QByteArray UrlTemp(IncomingUrl.toUtf8());
        IncomingUrl = QUrl::fromPercentEncoding(UrlTemp);
        
        QUrl url(IncomingUrl);@
        

        Worked for me.

        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