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


C++ QNetworkAccessManager::setObjectName方法代码示例

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


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

示例1: getBlogs

void WPUtils::getBlogs(QString u, QString p, QString blog_address)
{
	_xml.clear();
	QXmlStreamWriter sw(&_xml);

	sw.setAutoFormatting(true);
	sw.writeStartDocument();

	sw.writeStartElement("methodCall");
	sw.writeTextElement("methodName", "wp.getUsersBlogs");

	sw.writeStartElement("params");
	sw.writeStartElement("param");
	sw.writeCharacters("username");
	sw.writeTextElement("value", u);
	sw.writeEndElement();
	sw.writeStartElement("param");
	sw.writeCharacters("password");
	sw.writeTextElement("value", p);
	sw.writeEndElement();

	sw.writeEndDocument();

	QNetworkAccessManager *manager = new QNetworkAccessManager();

	manager->setObjectName("getUsersBlogs");

	QObject::connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));

	QUrl url;

	//_xml = xml.toUtf8();

	QString tmp_url = searchEndPoint(blog_address);
	if ( tmp_url.isEmpty() )
	{
		qDebug() << "unable to found endpoint";
		res.insert("ERROR","ERROR");
	} else {

		url.setUrl(tmp_url);
		QNetworkRequest request(url);
		int cmd = 0;
		request.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 1), QVariant((int) cmd)); /* not sure */
		request.setRawHeader("User-Agent", "wp-bb10/0.0.1");
		request.setHeader(QNetworkRequest::ContentTypeHeader, "text/xml");

		manager->post(request,_xml);
	}
}
开发者ID:b0unc3,项目名称:WordPress-bb10,代码行数:50,代码来源:WPUtils.cpp

示例2: buildWPXML

void WPUtils::buildWPXML(QString mName, bool standardParams,
		QStringList other_paramsNames, QStringList other_paramsValues,
		QStringList memberNames , QStringList memberValues)

{
	qDebug() << "bwpx : endpoint on = " << _endpoint;
	QByteArray _xml;
	QXmlStreamWriter sw(&_xml);

	sw.setAutoFormatting(true);
	sw.writeStartDocument();

	sw.writeStartElement("methodCall");
	sw.writeTextElement("methodName", mName);

	sw.writeStartElement("params");

	if ( standardParams )
	{
		sw.writeStartElement("param");
		sw.writeCharacters("blog_id");
		sw.writeTextElement("value", _blogid);
		sw.writeEndElement();

		sw.writeStartElement("param");
		sw.writeCharacters("username");
		sw.writeTextElement("value", _username);
		sw.writeEndElement();

		sw.writeStartElement("param");
		sw.writeCharacters("password");
		sw.writeTextElement("value", _password);
		sw.writeEndElement();
	}

	int i;

	for ( i=0; i<other_paramsNames.size(); i++ )
	{
		sw.writeStartElement("param");
		sw.writeCharacters(other_paramsNames.at(i).toLocal8Bit().constData());
		sw.writeTextElement("value", other_paramsValues.at(i).toLocal8Bit().constData());
		sw.writeEndElement();
	}
	sw.writeEndElement();
	if ( memberNames.size() > 0 )
	{
		sw.writeStartElement("struct");

		for ( i = 0; i < memberNames.size(); i++ )
		{
			sw.writeStartElement("member");
			sw.writeTextElement("name", memberNames.at(i).toLocal8Bit().constData());
			sw.writeTextElement("value", memberValues.at(i).toLocal8Bit().constData());
			sw.writeEndElement();

		}

		sw.writeEndElement();
	}


	sw.writeEndDocument();

	QNetworkAccessManager *manager = new QNetworkAccessManager();

	mName.replace("deletePost","delPost", Qt::CaseSensitive);
	mName.replace("deleteComment", "delComment", Qt::CaseSensitive);
	if ( memberValues.contains("page", Qt::CaseSensitive) )
		mName.replace("Post", "Page", Qt::CaseInsensitive);

	manager->setObjectName(mName.replace("wp.",""));

	QObject::connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));

	QUrl url;

	url.setUrl(_endpoint);
	QNetworkRequest request(url);
	int cmd = 0;
	request.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 1), QVariant((int) cmd)); /* not sure */
	request.setRawHeader("User-Agent", "wp-bb10/0.0.1");
	request.setHeader(QNetworkRequest::ContentTypeHeader, "text/xml");

	manager->post(request,_xml);
}
开发者ID:b0unc3,项目名称:WordPress-bb10,代码行数:86,代码来源:WPUtils.cpp


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