本文整理汇总了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);
}
}
示例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);
}