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


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

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


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

示例1: getUpdateUrl

QString DNSUpdater::getUpdateUrl() const
{
    QUrl url;
#ifdef QT_NO_OPENSSL
    url.setScheme("http");
#else
    url.setScheme("https");
#endif
    url.setUserName(m_username);
    url.setPassword(m_password);

    Q_ASSERT(!m_lastIP.isNull());
    // Service specific
    switch (m_service) {
    case DNS::DYNDNS:
        url.setHost("members.dyndns.org");
        break;
    case DNS::NOIP:
        url.setHost("dynupdate.no-ip.com");
        break;
    default:
        qWarning() << "Unrecognized Dynamic DNS service!";
        Q_ASSERT(0);
    }
    url.setPath("/nic/update");

    QUrlQuery urlQuery(url);
    urlQuery.addQueryItem("hostname", m_domain);
    urlQuery.addQueryItem("myip", m_lastIP.toString());
    url.setQuery(urlQuery);
    Q_ASSERT(url.isValid());

    qDebug() << Q_FUNC_INFO << url.toString();
    return url.toString();
}
开发者ID:elFarto,项目名称:qBittorrent,代码行数:35,代码来源:dnsupdater.cpp

示例2: getTranslation

void Wikipedia::getTranslation()
{
    if (langCode().isEmpty() || entry().isEmpty()) {
        return;
    }

    QSettings s;
    QString lang = s.value(QStringLiteral("display/language")).toString().left(2).toUpper();
    if (lang.isEmpty() || (lang == QLatin1String("C"))) {
        lang = QLocale::system().name().left(2);
    }

    QUrl wpURL;
    wpURL.setScheme(QStringLiteral("https"));


    if (lang == langCode()) {
        wpURL.setHost(QStringLiteral("%1.wikipedia.org").arg(langCode()));
        wpURL.setPath(QStringLiteral("/wiki/%1").arg(entry()));
    } else {

        QString enFallback;

        QMap<QString, QString> interWiki = reqTranslations(langCode(), entry());
        if (interWiki.contains(QStringLiteral("en"))) {
            enFallback = interWiki.value(QStringLiteral("en"));
        }

        while (!interWiki.contains(lang) && (interWiki[QStringLiteral("cont")] != QStringLiteral(""))) {

            interWiki = reqTranslations(langCode(), entry(), interWiki[QStringLiteral("cont")]);

            if (interWiki.contains(QStringLiteral("en"))) {
                enFallback = interWiki.value(QStringLiteral("en"));
            }
        }

        if (interWiki.contains(lang)) {
            wpURL.setHost(QStringLiteral("%1.wikipedia.org").arg(lang));
            wpURL.setPath(QStringLiteral("/wiki/%1").arg(interWiki[lang]));
        } else if (!enFallback.isEmpty()) {
            wpURL.setHost(QStringLiteral("en.wikipedia.org"));
            wpURL.setPath(QStringLiteral("/wiki/%1").arg(enFallback));
        } else {
            wpURL.setHost(QStringLiteral("%1.wikipedia.org").arg(langCode()));
            wpURL.setPath(QStringLiteral("/wiki/%1").arg(entry()));
        }

#ifdef QT_DEBUG
        qDebug() << "Wikipedia URL: " << wpURL;
#endif

    }

    setUrl(wpURL);
}
开发者ID:Buschtrommel,项目名称:Chennzeihhan,代码行数:56,代码来源:wikipedia.cpp

示例3: QObject

WebFetch::WebFetch(QUrl url, QObject *obj, const char *slot) : QObject(), qoObject(obj), cpSlot(slot) {
	url.setScheme(QLatin1String("http"));

	// Fix in case the regional host is broken
	url.setHost(g.s.qsRegionalHost);
	if (url.host() != g.s.qsRegionalHost)
		url.setHost(QLatin1String("mumble.info"));

	qnr = Network::get(url);
	connect(qnr, SIGNAL(finished()), this, SLOT(finished()));
	connect(this, SIGNAL(fetched(QByteArray,QUrl,QMap<QString,QString>)), obj, slot);
}
开发者ID:RockManRock,项目名称:mumble,代码行数:12,代码来源:WebFetch.cpp

示例4: Init

  void TcpAddress::Init(const QString &ip, int port)
  {
    bool valid = true;

    if(port < 0 || port > 65535) {
      qWarning() << "Invalid port:" << port;
      valid = false;
    }

    QHostAddress host(ip);
    if(host.toString() != ip) {
      qWarning() << "Invalid IP:" << ip;
      valid = false;
    }

    if(host == QHostAddress::Null) {
      host = QHostAddress::Any;
    }

    QUrl url;
    url.setScheme(Scheme);
    url.setHost(ip);
    url.setPort(port);

    _data = new TcpAddressData(url, host, port, valid);
  }
开发者ID:nya2,项目名称:Dissent,代码行数:26,代码来源:TcpAddress.cpp

示例5: getApiUrl

static QUrl getApiUrl(BtsApi_private *p, const QString &method, const QueryList &querylist = QueryList())
{
	assertClient(p);

	QUrl res;

	res.setScheme("http");

	res.setHost(p->client->getHost());
	res.setPort(p->client->getPort());

	if(!p->client->getUserName().isEmpty())
		res.setUserName(p->client->getUserName());

	if(!p->client->getPassword().isEmpty())
		res.setPassword(p->client->getPassword());

	res.setPath("/api");

	QUrlQuery urlQuery;
	urlQuery.addQueryItem("method", method);

	for(const QueryPair &qp: querylist)
	{
		if(qp.second.isNull())
			urlQuery.addQueryItem(qp.first, "");
		else
			urlQuery.addQueryItem(qp.first, qp.second);
	}

	res.setQuery(urlQuery);

	return res;
}
开发者ID:BtbN,项目名称:btsync-qt,代码行数:34,代码来源:bts_api.cpp

示例6: QNetworkReply

MsgPartNetworkReply::MsgPartNetworkReply(MsgPartNetAccessManager *parent, const QPersistentModelIndex &part, bool requireFormatting):
    QNetworkReply(parent), part(part), formattedBufferContent(0), requireFormatting(requireFormatting)
{
    QUrl url;
    url.setScheme(QLatin1String("trojita-imap"));
    url.setHost(QLatin1String("msg"));
    url.setPath(part.data(Imap::Mailbox::RolePartPathToPart).toString());
    setUrl(url);

    setOpenMode(QIODevice::ReadOnly | QIODevice::Unbuffered);
    Q_ASSERT(part.isValid());
    const Mailbox::Model *model = 0;
    Mailbox::Model::realTreeItem(part, &model);
    Q_ASSERT(model);

    connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(slotModelDataChanged(QModelIndex,QModelIndex)));

    //TODO: fileDownloadProgress signal in model signal the process of the current download.
    //      This reply might not be the current download, but now we assume that because the only use case here
    //      is just see the download progress of attachments that is usually the only downloading event.
    //      Should match message UID and partId and then emit downloadProgress.
    connect(model, SIGNAL(fileDownloadProgress(qint64, qint64)), this, SIGNAL(downloadProgress(qint64,qint64)));

    Mailbox::TreeItemPart *partPtr = dynamic_cast<Mailbox::TreeItemPart *>(static_cast<Mailbox::TreeItem *>(part.internalPointer()));
    Q_ASSERT(partPtr);

    // We have to ask for contents before we check whether it's already fetched
    partPtr->fetch(const_cast<Mailbox::Model *>(model));
    // The part data might be already unavailable or already fetched
    QTimer::singleShot(0, this, SLOT(slotMyDataChanged()));

    buffer.setBuffer(partPtr->dataPtr());
    buffer.open(QIODevice::ReadOnly);
}
开发者ID:ubuntu-touch-apps,项目名称:dekko,代码行数:34,代码来源:MsgPartNetworkReply.cpp

示例7: toolControlChannel

QUrl DesktopDevice::toolControlChannel(const ControlChannelHint &) const
{
    QUrl url;
    url.setScheme(Utils::urlTcpScheme());
    url.setHost("localhost");
    return url;
}
开发者ID:choenig,项目名称:qt-creator,代码行数:7,代码来源:desktopdevice.cpp

示例8: QNetworkReply

MsgPartNetworkReply::MsgPartNetworkReply(MsgPartNetAccessManager *parent, const QPersistentModelIndex &part):
    QNetworkReply(parent), part(part)
{
    QUrl url;
    url.setScheme(QStringLiteral("trojita-imap"));
    url.setHost(QStringLiteral("msg"));
    url.setPath(part.data(Imap::Mailbox::RolePartPathToPart).toString());
    setUrl(url);

    setOpenMode(QIODevice::ReadOnly | QIODevice::Unbuffered);
    Q_ASSERT(part.isValid());

    connect(part.model(), &QAbstractItemModel::dataChanged, this, &MsgPartNetworkReply::slotModelDataChanged);

    // We have to ask for contents before we check whether it's already fetched
    part.data(Imap::Mailbox::RolePartData);

    // The part data might be already unavailable or already fetched
    QTimer::singleShot(0, this, SLOT(slotMyDataChanged()));

    QByteArray* bufferPtr = part.data(Imap::Mailbox::RolePartBufferPtr).value<QByteArray*>();
    Q_ASSERT(bufferPtr);
    buffer.setBuffer(bufferPtr);
    buffer.open(QIODevice::ReadOnly);
}
开发者ID:ChristopherCotnoir,项目名称:trojita,代码行数:25,代码来源:MsgPartNetworkReply.cpp

示例9: setHost

int Url::setHost ( lua_State * L )// ( const QString & host )
{
	QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
	//QString* host = ValueInstaller2<QString>::check( L, 2 );
	lhs->setHost( Util::toString( L, 2 ) );
	return 0;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlUrl.cpp

示例10: getCurrentUrl

void MumbleDBus::getCurrentUrl(const QDBusMessage &msg) {
	if (!g.sh || !g.sh->isRunning() || ! g.uiSession) {
		QDBusConnection::sessionBus().send(msg.createErrorReply(QLatin1String("net.sourceforge.mumble.Error.connection"), QLatin1String("Not connected")));
		return;
	}
	QString host, user, pw;
	unsigned short port;
	QUrl u;

	g.sh->getConnectionInfo(host, port, user, pw);
	u.setScheme(QLatin1String("mumble"));
	u.setHost(host);
	u.setPort(port);
	u.setUserName(user);

#if QT_VERSION >= 0x050000
	QUrlQuery query;
	query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0"));
	u.setQuery(query);
#else
	u.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0"));
#endif

	QStringList path;
	Channel *c = ClientUser::get(g.uiSession)->cChannel;
	while (c->cParent) {
		path.prepend(c->qsName);
		c = c->cParent;
	}
	u.setPath(path.join(QLatin1String("/")));
	QDBusConnection::sessionBus().send(msg.createReply(QString::fromLatin1(u.toEncoded())));
}
开发者ID:Abextm,项目名称:mumble,代码行数:32,代码来源:DBus.cpp

示例11: QNetworkRequest

void
SendLogsRequest::send()
{
    QUrl url;
    url.setScheme( "http" );
    url.setHost( "oops.last.fm" );
    url.setPath( "logsubmission/add" );
    url.addEncodedQueryItem( "username", QUrl::toPercentEncoding(Ws::Username) );
    #ifdef Q_WS_MAC
        url.addQueryItem( "platform", "macosx" );
    #elif defined WIN32
        url.addQueryItem( "platform", "win32" );
    #else
        url.addQueryItem( "platform", "linux" );
    #endif
    url.addQueryItem( "clientname", QCoreApplication::applicationName() );
    url.addQueryItem( "clientversion", QCoreApplication::applicationVersion() );

    QNetworkRequest request = QNetworkRequest( url );
    request.setRawHeader( "Content-Type", "multipart/form-data;boundary=8e61d618ca16" );
    request.setRawHeader( "Accept", "*/*" );

    m_data.append( postData( "usernotes", escapeString( m_usernotes ).toLatin1() ) );
    m_data.append( postData( "logs", m_logs.join(",").toLatin1() ) );
    m_data.append( "--8e61d618ca16--" ); // close the post request
    
    m_error = false;
    QNetworkReply *reply = (new WsAccessManager( this ))->post( request, m_data );
    
    connect( reply, SIGNAL( finished() ),
             this, SLOT( onFinished() ) );
    connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
             this, SLOT( onError( QNetworkReply::NetworkError ) ) );
}
开发者ID:AICIDNN,项目名称:lastfm-desktop,代码行数:34,代码来源:SendLogsRequest.cpp

示例12: parse

    /* The parse function is invoked after the loadFinished signal is received 
     * from  the webkit code upon successfully parsing a page. From here, the 
     * entire DOM can be manipulated and traversed really conveniently. The 
     * code right now just traverses the DOM looking for link tags, and queues 
     * them if they are valid, but this function is where all of the 
     * interesting development will take place in the future. 
     */
   void Parser::parse() {
      QUrl currentUrl;
      QWebElementCollection linkTags =
         page->mainFrame()->findAllElements("a");

      foreach(QWebElement current, linkTags) {
         currentUrl = QUrl(current.attribute("href"));
         /* This discards the fragment. It is useless in this context and
          * will complicate our visited hashtable.
          */
         currentUrl.setEncodedFragment(QByteArray());

         if (currentUrl.isEmpty()) {
            continue;
         }

         /* Prepend the parent URL if we have a relative link in an attempt
          * to validate it for retrieval.
          */
         if (currentUrl.isRelative() &&
            currentUrl.host() == "" && currentUrl.path() != "") {
            qDebug() << currentUrl << " is relative path. prepending host";
            currentUrl.setHost(url.host());
            currentUrl.setScheme(url.scheme());
            qDebug() << "with host fix: " << currentUrl;
         }

         /* Finally, check to make sure it's valid before queueing it */
         if (validateUrl(currentUrl)) {
            parsedUrls.push_back(currentUrl);
         }
      }
开发者ID:gosom,项目名称:slurp,代码行数:39,代码来源:parser.cpp

示例13: hostLookuped

void MainWidget::hostLookuped(QHostInfo hostInfo)
{
    m_v4Addr.clear();
    m_v6Addr.clear();

    qDebug() << "ipV6 addresses:";
    for( auto address: hostInfo.addresses()){
        if( address.protocol() == QAbstractSocket::IPv6Protocol ){
            qDebug() << "  " << address;
            m_v6Addr = address;
            break;
        }
    }
    qDebug() << "ipV4 addresses:";
    for( auto address: hostInfo.addresses()){
        if( address.protocol() == QAbstractSocket::IPv4Protocol ){
            qDebug() << "  " << address;
            m_v4Addr = address;
            break;
        }
    }

    if(! m_v6Addr.isNull()){
        QUrl url;
        url.setScheme("http");
        url.setHost(m_v6Addr.toString());
        qDebug() << "request to " << url;

        connect(m_naman,SIGNAL(finished(QNetworkReply*)),
                this,SLOT(replyFinishedV6(QNetworkReply*)));
        m_naman->get(QNetworkRequest(url));
    }
开发者ID:osamu-k,项目名称:QtStudy,代码行数:32,代码来源:mainwidget.cpp

示例14: run

void BookmarksRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &action)
{
    Q_UNUSED(context);
    const QString term = action.data().toString();
    QUrl url = QUrl(term);

    //support urls like "kde.org" by transforming them to http://kde.org
    if (url.scheme().isEmpty()) {
        const int idx = term.indexOf('/');

        url.clear();
        url.setHost(term.left(idx));
        if (idx != -1) {
            //allow queries
            const int queryStart = term.indexOf('?', idx);
            int pathLength = -1;
            if ((queryStart > -1) && (idx < queryStart)) {
                pathLength = queryStart - idx;
                url.setQuery(term.mid(queryStart));
            }

            url.setPath(term.mid(idx, pathLength));
        }
        url.setScheme(QStringLiteral("http"));
    }

    KToolInvocation::invokeBrowser(url.url());
}
开发者ID:cmacq2,项目名称:plasma-workspace,代码行数:28,代码来源:bookmarksrunner.cpp

示例15: setRubyProxyEnvironment

void PatMainWindow::setRubyProxyEnvironment(const QNetworkProxy &t_proxy)
{
  OS_ASSERT(t_proxy.type() == QNetworkProxy::NoProxy || t_proxy.type() == QNetworkProxy::HttpProxy);

  if (t_proxy.type() == QNetworkProxy::NoProxy)
  {
    LOG(Info, "Clearing proxy environment variables");
    bool set = qputenv("HTTP_PROXY", QByteArray());
    OS_ASSERT(set);
    set = qputenv("HTTP_PROXY_USER", QByteArray());
    OS_ASSERT(set);
    set = qputenv("HTTP_PROXY_PASS", QByteArray());
    OS_ASSERT(set);
    set = qputenv("HTTP_USER", QByteArray());
    OS_ASSERT(set);
    set = qputenv("HTTP_PASS", QByteArray());
    OS_ASSERT(set);
  } else if (t_proxy.type() == QNetworkProxy::HttpProxy) {
    LOG(Info, "Clearing proxy environment variables");
    QUrl urlsimple;
    urlsimple.setHost(t_proxy.hostName());
    urlsimple.setPort(t_proxy.port());
    urlsimple.setScheme("http");
    bool set = qputenv("HTTP_PROXY", urlsimple.toString().toLatin1());
    OS_ASSERT(set);
    set = qputenv("HTTP_PROXY_USER", t_proxy.user().toLatin1());
    OS_ASSERT(set);
    set = qputenv("HTTP_PROXY_PASS", t_proxy.password().toLatin1());
    OS_ASSERT(set);
    set = qputenv("HTTP_USER", t_proxy.user().toLatin1());
    OS_ASSERT(set);
    set = qputenv("HTTP_PASS", t_proxy.password().toLatin1());
    OS_ASSERT(set);
  }
}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:35,代码来源:PatMainWindow.cpp


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