本文整理汇总了C++中QUrl::setUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::setUrl方法的具体用法?C++ QUrl::setUrl怎么用?C++ QUrl::setUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::setUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uriTests
void URITests::uriTests()
{
SendCoinsRecipient rv;
QUrl uri;
uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?req-dontexist="));
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?dontexist="));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 0);
uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?label=Some Example Address"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString("Some Example Address"));
QVERIFY(rv.amount == 0);
uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=0.001"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 100000);
uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=1.001"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 100100000);
uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=100&label=Some Example"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.amount == 10000000000LL);
QVERIFY(rv.label == QString("Some Example"));
uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?message=Some Example Address"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
QVERIFY(GUIUtil::parseBitcoinURI("chaincoin://XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?message=Some Example Address", &rv));
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?req-message=Some Example Address"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=1,000&label=Some Example"));
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
uri.setUrl(QString("chaincoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=1,000.0&label=Some Example"));
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
}
示例2: randomfile
QUrl PouarQuick::randomfile(QUrl url)
{
QDir dir(url.toLocalFile());
QFileInfoList dirs = QFileInfoList(dir.entryInfoList(QDir::Files));
if(dirs.size()>0)
{
dir.setPath(dirs.at(arc4random_uniform(dirs.size())).filePath());
url.setUrl("file://"+dir.absolutePath());
}
else
url.setUrl("file:///dev/null");
return url;
}
示例3: loadData
/**
* @brief Starts network requests to download infos from TMDb
* @param id TMDb movie ID
* @param concert Concert object
* @param infos List of infos to load
* @see TMDbConcerts::loadFinished
* @see TMDbConcerts::loadCastsFinished
* @see TMDbConcerts::loadTrailersFinished
* @see TMDbConcerts::loadImagesFinished
* @see TMDbConcerts::loadReleasesFinished
*/
void TMDbConcerts::loadData(QString id, Concert *concert, QList<int> infos)
{
qDebug() << "Entered, id=" << id << "concert=" << concert->name();
concert->setTmdbId(id);
m_infosToLoad = infos;
m_currentConcert = concert;
m_currentConcert->clear(infos);
m_currentId = id;
m_loadDoneFired = false;
m_loadsLeft.clear();
QUrl url;
QNetworkRequest request;
request.setRawHeader("Accept", "application/json");
// Infos
m_loadsLeft.append(DataInfos);
url.setUrl(QString("http://api.themoviedb.org/3/movie/%1?api_key=%2&language=%3").arg(id).arg(m_apiKey).arg(m_language));
request.setUrl(url);
m_loadReply = this->qnam()->get(QNetworkRequest(request));
connect(m_loadReply, SIGNAL(finished()), this, SLOT(loadFinished()));
// Trailers
if (m_infosToLoad.contains(ConcertScraperInfos::Trailer)) {
m_loadsLeft.append(DataTrailers);
url.setUrl(QString("http://api.themoviedb.org/3/movie/%1/trailers?api_key=%2").arg(m_currentId).arg(m_apiKey));
request.setUrl(url);
m_trailersReply = this->qnam()->get(QNetworkRequest(request));
connect(m_trailersReply, SIGNAL(finished()), this, SLOT(loadTrailersFinished()));
}
// Images
if (m_infosToLoad.contains(ConcertScraperInfos::Poster) || m_infosToLoad.contains(ConcertScraperInfos::Backdrop)) {
m_loadsLeft.append(DataImages);
url.setUrl(QString("http://api.themoviedb.org/3/movie/%1/images?api_key=%2").arg(m_currentId).arg(m_apiKey));
request.setUrl(url);
m_imagesReply = this->qnam()->get(QNetworkRequest(request));
connect(m_imagesReply, SIGNAL(finished()), this, SLOT(loadImagesFinished()));
}
// Releases
if (m_infosToLoad.contains(ConcertScraperInfos::Certification)) {
m_loadsLeft.append(DataReleases);
url.setUrl(QString("http://api.themoviedb.org/3/movie/%1/releases?api_key=%2").arg(m_currentId).arg(m_apiKey));
request.setUrl(url);
m_releasesReply = this->qnam()->get(QNetworkRequest(request));
connect(m_releasesReply, SIGNAL(finished()), this, SLOT(loadReleasesFinished()));
}
}
示例4: getTimeTableForStation
void ParserResRobot::getTimeTableForStation(const Station ¤tStation,
const Station &directionStation,
const QDateTime &dateTime,
ParserAbstract::Mode mode,
int trainrestrictions)
{
if (currentRequestState != FahrplanNS::noneRequest)
return;
currentRequestState = FahrplanNS::getTimeTableForStationRequest;
timetableSearchMode = mode;
QUrl url;
if (mode == Arrival)
url.setUrl(baseURL + QLatin1String("/arrivalBoard"));
else
url.setUrl(baseURL + QLatin1String("/departureBoard"));
#if defined(BUILD_FOR_QT5)
QUrlQuery query;
#else
QUrl query;
#endif
query.addQueryItem("key", timetableAPIKey);
query.addQueryItem("id", stationIDv2(currentStation.id.toString()));
if (directionStation.valid)
query.addQueryItem("direction", stationIDv2(directionStation.id.toString()));
query.addQueryItem("date", dateTime.toString("yyyy-MM-dd"));
query.addQueryItem("time", dateTime.toString("hh:mm"));
query.addQueryItem("maxJourneys", "30"); // Max number of results
query.addQueryItem("passlist", "0"); // We don't need any intermediate stops in the result
QString formattedRestrictions(formatRestrictions(trainrestrictions));
if (!formattedRestrictions.isEmpty())
query.addQueryItem("products", formattedRestrictions);
if (QLocale().language() == QLocale::Swedish)
query.addQueryItem("lang", "sv");
else if (QLocale().language() == QLocale::German)
query.addQueryItem("lang", "de");
else
query.addQueryItem("lang", "en");
query.addQueryItem("format", "json");
#if defined(BUILD_FOR_QT5)
url.setQuery(query);
#else
url.setQueryItems(query.queryItems());
#endif
qDebug() << "Searching for timetable:" << url.toString();
sendHttpRequest(url);
}
示例5: realDownload
void CoverHelper::realDownload() {
QUrl url;
url.setUrl("http://images.grooveshark.com/static/albums/500_" + QString::fromStdString(currentCover));
QNetworkRequest request;
request.setUrl(url);
manager->get(request);
}
示例6: serviceUrl
QString serviceUrl( const QgsServerRequest &request, const QgsProject *project )
{
QUrl href;
if ( project )
{
href.setUrl( QgsServerProjectUtils::wfsServiceUrl( *project ) );
}
// Build default url
if ( href.isEmpty() )
{
static QSet<QString> sFilter
{
QStringLiteral( "REQUEST" ),
QStringLiteral( "VERSION" ),
QStringLiteral( "SERVICE" ),
};
href = request.originalUrl();
QUrlQuery q( href );
for ( auto param : q.queryItems() )
{
if ( sFilter.contains( param.first.toUpper() ) )
q.removeAllQueryItems( param.first );
}
href.setQuery( q );
}
return href.toString();
}
示例7: doStart
void DecoderHandler::doStart(bool result)
{
doOperationStop();
QUrl url;
if (QFileInfo(m_meta->Filename()).isAbsolute())
url = QUrl::fromLocalFile(m_meta->Filename());
else
url.setUrl(m_meta->Filename());
if (m_state == LOADING && result)
{
for (int ii = 0; ii < m_playlist.size(); ii++)
LOG(VB_PLAYBACK, LOG_INFO, QString("Track %1 = %2")
.arg(ii) .arg(m_playlist.get(ii)->File()));
next();
}
else
{
if (m_state == STOPPED)
{
doFailed(url, "Could not get playlist");
}
}
}
示例8: readData
QmcUnit *QmcUnit::loadUnit(QDataStream &stream, QQmlEngine *engine, QmcLoader *loader, const QUrl &loadedUrl)
{
//qDebug() << "Loading" << loadedUrl;
QmcUnitHeader *header = new QmcUnitHeader;
bool ret = readData((char *)header, sizeof(QmcUnitHeader), stream);
if (!ret || !checkHeader(header)) {
delete header;
return NULL;
}
QString name;
QString urlString;
if (!readString(name, stream) || !readString(urlString, stream)) {
delete header;
return NULL;
}
QUrl url;
url.setUrl(urlString);
QmcUnit *unit = new QmcUnit(header, url, urlString, engine, loader, name, loadedUrl);
if (unit->loadUnitData(stream))
return unit;
unit->blob->release();
return NULL;
}
示例9: addMessage
/*
* Add message request set
*/
void ElisaServer::addMessage(QString body, double latitude, double longitude)
{
//check if user is already logged
if(m_nickname!=""){
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
//set urls
QUrl url;
url.setUrl("http://projectelisa.altervista.org/main/post/?x="+QString::number(latitude,'g',10)+"&y="+QString::number(longitude,'g',10)+"&z=0&nick="+temp_nickname+"&pass="+temp_password);
//add post params
QByteArray postData;
postData.append("body="+body);
//bind network request
QNetworkRequest request;
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
request.setUrl(url);
//define callback
QNetworkReply * r;
r = manager->post(request, postData);
connect(r,SIGNAL(finished()),this,SLOT(addMessageFinished()));
} else {
emit addMessageReply("denied");
}
}
示例10: playNPVSong
void MpFetcherTestAppView::playNPVSong()
{
QUrl url;
url.setUrl("appto://10207C62?activityname=MusicNowPlayingView&launchtype=standalone&uri=" + mResultEdit->text() );
if(mReq){
delete mReq;
mReq = 0;
}
mReq = mAppMgr.create(url);
if (mReq == NULL)
{
// No handlers for the URI
return;
}
mReq->setBackground(false);
// Send the request
bool res = mReq->send();
if (!res)
{
// Request failed.
int error = mReq->lastError();
// Handle error
}
}
示例11: openWithExternalViewer
void UIImageViewer::openWithExternalViewer() {
QUrl url;
if (currentImage != -1 && imagesToDisplay.count() > currentImage) {
url.setUrl(QString("file:///%1").arg(imagesToDisplay.at(currentImage)));
QDesktopServices::openUrl(url);
}
}
示例12: start
void DecoderHandler::start(Metadata *mdata)
{
m_state = LOADING;
m_playlist.clear();
m_meta = mdata;
m_playlist_pos = -1;
m_redirects = 0;
QUrl url;
if (QFileInfo(mdata->Filename()).isAbsolute())
url = QUrl::fromLocalFile(mdata->Filename());
else
url.setUrl(mdata->Filename());
bool result = createPlaylist(url);
if (m_state == LOADING && result)
{
for (int ii = 0; ii < m_playlist.size(); ii++)
VERBOSE(VB_PLAYBACK, QString("Track %1 = %2")
.arg(ii)
.arg(m_playlist.get(ii)->File()));
next();
}
else
{
if (m_state != STOPPED)
{
doFailed(url, "Could not get playlist");
}
}
}
示例13: serviceUrl
QUrl serviceUrl( const QgsServerRequest &request, const QgsProject *project )
{
QUrl href;
if ( project )
{
href.setUrl( QgsServerProjectUtils::wmsServiceUrl( *project ) );
}
// Build default url
if ( href.isEmpty() )
{
href = request.url();
QUrlQuery q( href );
q.removeAllQueryItems( QStringLiteral( "REQUEST" ) );
q.removeAllQueryItems( QStringLiteral( "VERSION" ) );
q.removeAllQueryItems( QStringLiteral( "SERVICE" ) );
q.removeAllQueryItems( QStringLiteral( "LAYERS" ) );
q.removeAllQueryItems( QStringLiteral( "SLD_VERSION" ) );
q.removeAllQueryItems( QStringLiteral( "_DC" ) );
href.setQuery( q );
}
return href;
}
示例14: requestMetadata
void SM_QDropbox::requestMetadata(QString file, bool blocking)
{
clearError();
timestamp = QDateTime::currentMSecsSinceEpoch()/1000;
QUrl url;
url.setUrl(apiurl.toString());
QUrlQuery urlQuery;
urlQuery.addQueryItem("oauth_consumer_key",_appKey);
urlQuery.addQueryItem("oauth_nonce", nonce);
urlQuery.addQueryItem("oauth_signature_method", signatureMethodString());
urlQuery.addQueryItem("oauth_timestamp", QString::number(timestamp));
urlQuery.addQueryItem("oauth_token", oauthToken);
urlQuery.addQueryItem("oauth_version", _version);
QString signature = oAuthSign(url);
urlQuery.addQueryItem("oauth_signature", QUrl::toPercentEncoding(signature));
url.setQuery(urlQuery);
url.setPath(QString("/%1/metadata/%2").arg(_version.left(1), file));
int reqnr = sendRequest(url);
if(blocking)
{
requestMap[reqnr].type = SM_DROPBOX_REQ_BMETADA;
startEventLoop();
}
else
requestMap[reqnr].type = SM_DROPBOX_REQ_METADAT;
//SM_Dropbox_FileInfo fi(_tempJson.strContent(), this);
return;
}
示例15: requestSharedLink
void SM_QDropbox::requestSharedLink(QString file, bool blocking)
{
clearError();
QUrl url;
url.setUrl(apiurl.toString());
QUrlQuery urlQuery;
urlQuery.addQueryItem("oauth_consumer_key",_appKey);
urlQuery.addQueryItem("oauth_nonce", nonce);
urlQuery.addQueryItem("oauth_signature_method", signatureMethodString());
urlQuery.addQueryItem("oauth_timestamp", QString::number(timestamp));
urlQuery.addQueryItem("oauth_token", oauthToken);
urlQuery.addQueryItem("oauth_version", _version);
QString signature = oAuthSign(url);
urlQuery.addQueryItem("oauth_signature", QUrl::toPercentEncoding(signature));
url.setPath(QString("/%1/shares/%2").arg(_version.left(1), file));
url.setQuery(urlQuery);
int reqnr = sendRequest(url);
if(blocking)
{
requestMap[reqnr].type = SM_DROPBOX_REQ_BSHRDLN;
startEventLoop();
}
else
requestMap[reqnr].type = SM_DROPBOX_REQ_SHRDLNK;
return;
}