Mac
Mac

Reputation: 3559

How to join urls in QT

Python has a really hand functionality with urllib.parse.urljoin in which it handles joining urls, examples:

merging urls:

>>> urllib.parse.urljoin('https://something.a.com/api/v3/', 'some/end/point')
'https://something.a.com/api/v3/some/end/point'

I am looking at the QT documentation and I cannot find anything like this in there. How do people deal with this two situations? I guess I could manually merge things with QStrings, but that seems a bit cumbersome.

Upvotes: 4

Views: 585

Answers (1)

QUrl::resolved serves that purpose. It merges the relative URL passed as an argument with the base url given by the instance you call it on:

auto full = base.resolved(relative);

Upvotes: 5

Related Questions