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::resolved doesn't work
Forum Updated to NodeBB v4.3 + New Features

QUrl::resolved doesn't work

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

    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/"

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AndrewW
      wrote on last edited by
      #2

      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

      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