[Qt-interest] QUrl::path() leading slash bug?

Anthony Serdyukov uksus70 at gmail.com
Fri Jan 9 06:05:32 CET 2009


By the way, I have noticed some interesting and unexpected behavior.
Invoking const method causes other method to change it's return value!

		QUrl url("test.txt");
		url.setHost("some.net");
		url.setPort(1234);
		qDebug() << url.toEncoded();
		url.path();
		qDebug() << url.toEncoded();

output is following:
"//some.net:1234test.txt"
"//some.net:1234/test.txt"

Is this a bug?

2008/6/17 Anton Serdyukov <uksus70 at gmail.com>:
> Hi.
>
>
>
> I have a problem with QUrl.
>
> See the following code:
>
>
>
>       QUrl url1;
>
>       QUrl url2;
>
>
>
>       url1.setPath("test.txt");
>
>       url2.setPath("/test.txt");
>
>
>
>       url1.setHost("some.net");
>
>       url2.setHost("some.net");
>
>
>
>       url1.setPort(1234);
>
>       url2.setPort(1234);
>
>
>
>       url1.setScheme("http");
>
>       url2.setScheme("http");
>
>
>
>       qDebug() << url1.toString(); // "http://some.net:1234/test.txt"
>
>       qDebug() << url2.toString(); // "http://some.net:1234/test.txt"
>
>
>
>       qDebug() << url1.path(); // "test.txt"
>
>       qDebug() << url2.path(); // "/test.txt"
>
>
>
> Why path() remains different while toString() is the same? I want QUrl to be
> equivalent if toString() is the same.
>
> Ideas?



-- 
Regards,
Anthony



More information about the Qt-interest-old mailing list