当前位置: 首页>>代码示例>>C++>>正文


C++ QUrl::setQuery方法代码示例

本文整理汇总了C++中QUrl::setQuery方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::setQuery方法的具体用法?C++ QUrl::setQuery怎么用?C++ QUrl::setQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QUrl的用法示例。


在下文中一共展示了QUrl::setQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: openUrl_data

void tst_QDesktopServices::openUrl_data()
{
    QTest::addColumn<QUrl>("data");
    QTest::addColumn<QString>("message");

    QUrl localFile = QUrl::fromLocalFile(QFINDTESTDATA("test.txt"));

    QTest::newRow("text-file")
            << localFile
            << "This should open test.txt in a text editor";

    localFile.setQuery("x=y");
    QTest::newRow("text-file-with-query")
            << localFile
            << "This should open test.txt in a text editor. Queries do not usually show up.";

    localFile.setQuery(QString());
    localFile.setFragment("top");
    QTest::newRow("text-file-with-fragment")
            << localFile
            << "This should open test.txt in a text editor. Fragments do not usually show up.";

    QTest::newRow("browser-plain")
            << QUrl("http://qt-project.org")
            << "This should open http://qt-project.org in the default web browser";

    QTest::newRow("search-url")
            << QUrl("http://google.com/search?q=Qt+Project")
            << "This should search \"Qt Project\" on Google";

    QTest::newRow("search-url-with-space")
            << QUrl("http://google.com/search?q=Qt Project")
            << "This should search \"Qt Project\" on Google";

    QTest::newRow("search-url-with-quotes")
            << QUrl("http://google.com/search?q=\"Qt+Project\"")
            << "This should search '\"Qt Project\"' on Google (including the quotes)";

    QTest::newRow("search-url-with-hashtag")
            << QUrl("http://google.com/search?q=%23qtproject")
            << "This should search \"#qtproject\" on Google. The # should appear in the Google search field";

    QTest::newRow("search-url-with-fragment")
            << QUrl("http://google.com/search?q=Qt+Project#top")
            << "This should search \"Qt Project\" on Google. There should be no # in the Google search field";

    // see QTBUG-32311
    QTest::newRow("search-url-with-slashes")
            << QUrl("http://google.com/search?q=/profile/5")
            << "This should search \"/profile/5\" on Google.";

    QTest::newRow("mail")
            << QUrl("mailto:[email protected]")
            << "This should open an email composer with the destination set to [email protected]";

    QTest::newRow("mail-subject")
            << QUrl("mailto:[email protected]?subject=[Development]%20Test%20Mail")
            << "This should open an email composer and tries to set the subject";
}
开发者ID:cedrus,项目名称:qt,代码行数:59,代码来源:tst_qdesktopservices.cpp

示例2: 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();
  }
开发者ID:jonnyforestGIS,项目名称:QGIS,代码行数:33,代码来源:qgswfsutils.cpp

示例3: urlquery

void
TrainingstagebuchUploader::requestSession()
{
    parent->progressLabel->setText(tr("getting new Trainingstagebuch.org Session..."));

    currentRequest = reqSession;

    QString username = appsettings->cvalue(context->athlete->cyclist, GC_TTBUSER).toString();
    QString password = appsettings->cvalue(context->athlete->cyclist, GC_TTBPASS).toString();

#if QT_VERSION > 0x050000
    QUrlQuery urlquery;
#else
    QUrl urlquery( TTB_URL + "/login/sso" );
#endif
    urlquery.addQueryItem( "view", "xml" );
    urlquery.addQueryItem( "user", username );
    urlquery.addQueryItem( "pass", password );

#if QT_VERSION > 0x050000
    QUrl url (TTB_URL + "/login/sso");
    url.setQuery(urlquery.query());
    QNetworkRequest request = QNetworkRequest(url);
#else
    QNetworkRequest request = QNetworkRequest(urlquery);
#endif

    request.setRawHeader( "Accept-Encoding", "identity" );
    request.setRawHeader( "Accept", "application/xml" );
    request.setRawHeader( "Accept-Charset", "utf-8" );

    networkMgr.get( request );
    parent->progressBar->setValue(parent->progressBar->value()+5/parent->shareSiteCount);
}
开发者ID:JanDeVisser,项目名称:GoldenCheetah,代码行数:34,代码来源:TrainingstagebuchUploader.cpp

示例4: getFullOutputMappingURL

QUrl ModelBaker::getFullOutputMappingURL() const {
    QUrl appendedURL = _outputMappingURL;
    appendedURL.setFragment(_outputURLSuffix.fragment());
    appendedURL.setQuery(_outputURLSuffix.query());
    appendedURL.setUserInfo(_outputURLSuffix.userInfo());
    return appendedURL;
}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:7,代码来源:ModelBaker.cpp

示例5: 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;
}
开发者ID:AdrianBZG,项目名称:SyncMe,代码行数:34,代码来源:SM_qdropbox.cpp

示例6: QDialog

VkLoginDialog::VkLoginDialog(QWidget *parent) : QDialog(parent)
{
    qDebug() << __FUNCTION__;
    QUrl url;
    url.setScheme("https");
    url.setHost("oauth.vk.com");
    url.setPath("/authorize");

    QUrlQuery urlQuery;
    urlQuery.addQueryItem("client_id", "5042372");
    urlQuery.addQueryItem("display", "page");
    urlQuery.addQueryItem("redirect_uri", "https://oauth.vk.com/blank.html");
    urlQuery.addQueryItem("response_type", "token");
    urlQuery.addQueryItem("v", "5.37");
    urlQuery.addQueryItem("scope", "audio");
    url.setQuery(urlQuery);

    QWebView *webView = new QWebView(this);
    webView->load(url);

    connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(getTokenFromUrl(QUrl)));

    QGridLayout *layout = new QGridLayout(this);
    layout->addWidget(webView);
}
开发者ID:pavelalexeenko,项目名称:VkExternalPlayer,代码行数:25,代码来源:vklogindialog.cpp

示例7: loginReply

void SpotifyIO::loginReply()
{
    qDebug() << "resolver request";
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
    if (reply) {
        QByteArray data(reply->readAll());
        QVariantMap json = QJsonDocument::fromJson(data).toVariant().toMap();

        if (json["status"].toString() == "OK") {
            settings = json["config"].toMap();
            QVariantMap resolver = settings["aps"].toMap()["resolver"].toMap();

            QUrl url;
            url.setScheme("https");
            url.setHost(resolver["hostname"].toString());
            QUrlQuery query;
            query.addQueryItem("client", "24:0:0:" + settings["version"].toString());
            QString site = resolver["site"].toString();
            if (!site.isEmpty()) {
                query.addQueryItem("site", site);
            }
            url.setQuery(query);
            QNetworkRequest req(url);
            req.setHeader(QNetworkRequest::UserAgentHeader, userAgent);
            QObject::connect(nam->get(req), SIGNAL(finished()), this, SLOT(resolverReply()));
        }
        else {
            qDebug() << json["error"];
            Q_EMIT authFailed(json["error"].toString());

            _state = DisconnectedState;
            Q_EMIT stateChanged();
        }
    }
}
开发者ID:CODeRUS,项目名称:spotacular,代码行数:35,代码来源:spotifyio.cpp

示例8: modifyTeaching

void Data::modifyTeaching(int id, const QString &className, int subjectID, int group, int teacherID, const QColor &color)
{
    if (this->m_modifyReply) delete this->m_modifyReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/modifyTeaching.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("id", QString::number(id));
    params.addQueryItem("className", className);
    params.addQueryItem("subjectID", QString::number(subjectID));
    params.addQueryItem("group", QString::number(group));
    params.addQueryItem("teacherID", QString::number(teacherID));
    params.addQueryItem("color", QString::number((color.red() << 16) | (color.green() << 8) | (color.blue())));
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_modifyReply = this->m_manager->post(request, data);
    connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getTeachings()));
    //connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(readReady()));
}
开发者ID:TamasSzekeres,项目名称:Adatbazisok_KotProg,代码行数:29,代码来源:data.cpp

示例9: deleteRoom

void Data::deleteRoom(int id, bool refresh)
{
    if (this->m_modifyReply) delete this->m_modifyReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/deleteRoom.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("id", QString::number(id));
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_modifyReply = this->m_manager->post(request, data);
    if (refresh)
        connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getRooms()));
    //connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(readReady()));
}
开发者ID:TamasSzekeres,项目名称:Adatbazisok_KotProg,代码行数:25,代码来源:data.cpp

示例10: insertSubject

void Data::insertSubject(const QString &name, const QString &shortName)
{
    if (this->m_insertReply) delete this->m_insertReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/insertSubject.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("name", name);
    params.addQueryItem("shortName", shortName);
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_insertReply = this->m_manager->post(request, data);
    connect(this->m_insertReply, SIGNAL(finished()), this, SLOT(getSubjects()));
    //connect(this->m_insertReply, SIGNAL(finished()), this, SLOT(readReady()));
}
开发者ID:TamasSzekeres,项目名称:Adatbazisok_KotProg,代码行数:25,代码来源:data.cpp

示例11: modifyPeriods

void Data::modifyPeriods(const QTime times[9])
{
    if (this->m_modifyReply) delete this->m_modifyReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/modifyPeriods.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    for (int i = 0; i < 9; ++i) {
        params.addQueryItem(QString("s%1").arg(i + 1), times[i].toString("hh:mm"));
        params.addQueryItem(QString("e%1").arg(i + 1), times[i].addSecs(45 * 60).toString("hh:mm"));
    }
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_modifyReply = this->m_manager->post(request, data);
    connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getPeriods()));
}
开发者ID:TamasSzekeres,项目名称:Adatbazisok_KotProg,代码行数:26,代码来源:data.cpp

示例12: modifyClasses

void Data::modifyClasses(const QList<ClassData> &ocd, const QList<ClassData> &ncd, const QList<int> &ntid)
{
    int n = ocd.size();
    if (n <= 0) return;
    if (this->m_modifyReply) delete this->m_modifyReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/modifyClasses.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("n", QString::number(n));
    for (int i = 0; i < n; ++i) {
        const ClassData oc = ocd[i];
        const ClassData nc = ncd[i];
        params.addQueryItem(QString("ocid%1").arg(i), oc.name);
        params.addQueryItem(QString("ncid%1").arg(i), nc.name);
        params.addQueryItem(QString("nnum%1").arg(i), QString::number(nc.number));
        params.addQueryItem(QString("ntea%1").arg(i), QString::number(ntid[i]));
    }
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_modifyReply = this->m_manager->post(request, data);
    //connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(getSubjects()));
    connect(this->m_modifyReply, SIGNAL(finished()), this, SLOT(readReady()));
}
开发者ID:TamasSzekeres,项目名称:Adatbazisok_KotProg,代码行数:34,代码来源:data.cpp

示例13: insertLesson

void Data::insertLesson(int day, int hour, int teaching, int room)
{
    if ((day < 1) || (day > 5)) return;
    if ((hour < 1) || (hour > 9)) return;
    if ((teaching < 1) || (teaching > this->m_teachings.size())) return;
    if ((room < 1) || (room > this->m_rooms.size())) return;

    if (this->m_insertReply) delete this->m_insertReply;

    QUrl url = QUrl("http://szektam2.byethost3.com/insertLesson.php");

    PARAMS params;
    params.addQueryItem("username", Key::username());
    params.addQueryItem("password", Key::password());
    params.addQueryItem("day", QString::number(day));
    params.addQueryItem("hour", QString::number(hour));
    params.addQueryItem("teaching", QString::number(teaching));
    params.addQueryItem("room", QString::number(room));
    QByteArray data;
#if QT5
    data.append(params.toString());
    url.setQuery(params);
#else
    data.append(params.encodedQuery());
#endif

    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    this->m_insertReply = this->m_manager->post(request, data);
    connect(this->m_insertReply, SIGNAL(finished()), this, SLOT(getLessons()));
}
开发者ID:TamasSzekeres,项目名称:Adatbazisok_KotProg,代码行数:31,代码来源:data.cpp

示例14: searchUrl

/*!
    Constructs a suggestions URL with a given \a searchTerm.

    The URL template is processed according to the specification:
    http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_URL_template_syntax

    See searchUrl() for more information about processing template parameters.

    \sa suggestionsUrlTemplate(), suggestionsParameters(), searchUrl()
*/
QUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const
{
    if (!m_preparedSuggestionsUrl.isEmpty()) {
        QString s = m_preparedSuggestionsUrl;
        s.replace(QLatin1String("%s"), searchTerm);
        return QUrl(s);
    }

    if (m_suggestionsUrlTemplate.isEmpty()) {
        return QUrl();
    }

    QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8());

    QUrlQuery query(retVal);
    if (m_suggestionsMethod != QLatin1String("post")) {
        Parameters::const_iterator end = m_suggestionsParameters.constEnd();
        Parameters::const_iterator i = m_suggestionsParameters.constBegin();
        for (; i != end; ++i) {
            query.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
        }
        retVal.setQuery(query);
    }

    return retVal;
}
开发者ID:Acidburn0zzz,项目名称:qupzilla,代码行数:36,代码来源:opensearchengine.cpp

示例15: loadMetaData

bool DownloadManager::loadMetaData(IlwisObject *object, const IOOptions &options)
{
    QUrl url = _resource.url(true);
    QUrlQuery query(url);
    query.addQueryItem("datatype","metadata");
    query.removeQueryItem("ilwistype"); // ilwistype might be too generic so we replace it we a more accurate version
    QString ilwtype = IlwisObject::type2Name(_resource.ilwisType()).toLower();
    query.addQueryItem("ilwistype",ilwtype);
    url.setQuery(query);
    _object = object;
    QNetworkRequest request(url);

    QNetworkReply *reply = kernel()->network().get(request);

    connect(reply, &QNetworkReply::readyRead, this, &DownloadManager::readReady);
    connect(reply, &QNetworkReply::downloadProgress, this, &DownloadManager::downloadProgress);
    connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &DownloadManager::error);
    connect(reply, &QNetworkReply::finished, this, &DownloadManager::finishedMetadata);

    QEventLoop loop; // waits for request to complete
    connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
    loop.exec();

    delete reply;

    return true;
}
开发者ID:52North,项目名称:IlwisConnectors,代码行数:27,代码来源:downloadmanager.cpp


注:本文中的QUrl::setQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。