Results 1 to 3 of 3

Thread: QtUrl Problem with Windows 7 - 64 bit

  1. #1
    Join Date
    Oct 2012
    Posts
    6
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Windows

    Default QtUrl Problem with Windows 7 - 64 bit

    Our application is a 32 bit application . When it is installed in windows 7 64bit, typically it install at
    “C:\Program Files (x86)” location, instead of ““C:\Program Files”. We are constructing a Url based on the install location and and pass it around as a part of web service.The way , we are constructing the Url is like this –
    ppmPath = “http://” + ipAddress + “:13007/” + folder + “.ppm” + “?filePath=” + applicationDirPath + “/” + FIRMWARE;
    QUrl ppmURL( ppmPath, QUrl::TolerantMode ); ppmPath = QString( ppmURL.toEncoded() );

    The variable types and meaning are usual.
    Since “applicationDirPath” for Windows 7 64 bit contains one closing bracket “)” -for “(x86) substring – apparently the URL is broken. If we install it to any other location, it works perfectly, even though the
    location has any other special character.
    How to deal with “)” character in the URL , so that is is not broken ?

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtUrl Problem with Windows 7 - 64 bit

    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QtUrl Problem with Windows 7 - 64 bit

    Quote Originally Posted by vsthakur1 View Post
    How to deal with “)” character in the URL , so that is is not broken ?
    Use QUrl to build the URL in the first place (rather than pasting strings together). You'll find it does the encoding work for you.

    You will also find the open and close parentheses are perfectly legal characters in the query portion of a URL, but spaces are not.
    http://tools.ietf.org/html/rfc3986 (Section 3.4, 3.3, and 2.2)

    Qt Code:
    1. QUrl url;
    2. url.setScheme("http:");
    3. url.setHost(ipAddress);
    4. url.setPort(13007);
    5. url.setPath(QString("%1.ppm").arg(folder));
    6. url.addQueryItem("filepath", QString("%1/FIRMWARE").arg(applicationDirPath));
    7. qDebug() << url.toEncoded();
    8. // "http:://127.0.0.1:13007/some%20folder.ppm?filepath=C:/Program%20Files(x86)/SomeApplication/FIRMWARE"
    To copy to clipboard, switch view to plain text mode 

    Different systems are tolerant of badly formed URLs to different degrees, and incorrectly handle valid URLs also. If you are faced with a broken consumer of the URL then you can do this:
    Qt Code:
    1. url.addEncodedQueryItem(
    2. QUrl::toPercentEncoding("filepath"),
    3. QUrl::toPercentEncoding(QString("%1/FIRMWARE").arg(applicationDirPath))
    4. );
    5. qDebug() << url.toEncoded();
    6. // "http:://127.0.0.1:13007/some%20folder.ppm?filepath=C%3A%2FProgram%20Files%28x86%29%2FSomeApplication%2FFIRMWARE"
    To copy to clipboard, switch view to plain text mode 
    to be extra sure.

Similar Threads

  1. A problem with MDI windows
    By Datakim in forum Newbie
    Replies: 13
    Last Post: 17th April 2012, 08:12
  2. Replies: 19
    Last Post: 3rd April 2009, 23:17
  3. problem with Qt/ Windows--pls help
    By swamyonline in forum Installation and Deployment
    Replies: 8
    Last Post: 7th July 2008, 20:39
  4. Printing problem in windows
    By joseph in forum Qt Programming
    Replies: 6
    Last Post: 12th July 2007, 08:04
  5. Thread problem with windows
    By vratojr in forum Qt Programming
    Replies: 17
    Last Post: 16th June 2006, 08:34

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.