QUrl::resolved doesn't work
-
Hi
i try to run code as in the Documentation but with out success , what im missing here :
here is the code:@QString s("/About-us/");
QString base("http://qt.digia.com");
QString urlForReq;if(!s.startsWith("http:")) { QString uu = QUrl(s).toString(); QString rurl = baseUrl.resolved(QUrl(s)).toString(); urlForReq = rurl; }@
the urlForReq value is "/About-us/"
-
Some points stand out - line 2 shows 'base', whilst line 8 shows 'baseUrl', so you are dealing with different objects. Have you defined 'base' anywhere?
.resolved must follow a Qurl object, but you have 'baseUrl', which presuming you mean 'base', is a QString.
Try changing line 2 to:
Qurl baseUrl("http://qt.digia.com");
Also, line 7 seems pointless. You take a QString, change it to a Qurl, then convert back!
The scope of uu and rurl are only within the if statement, so you will not be able to use them later in your code.
Since urlForReq is a QString, you will not be able to use it as a Qurl without converting it later.
HTH