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


C++ QBuffer::setData方法代码示例

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


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

示例1: QBuffer

YandexNarodBuffer::YandexNarodBuffer(const QString &fileName, QIODevice *file,
									 const QByteArray &boundary, QObject *parent) :
	QIODevice(parent)
{
	QByteArray data;
	data.append("--").append(boundary).append("\r\n");
	data.append("Content-Disposition: form-data; name=\"file\"; filename=\"")
			.append(fileName).append("\"\r\n");
	data.append("Content-Transfer-Encoding: binary\r\n");
	data.append("\r\n");

	QBuffer *buffer = new QBuffer(this);
	buffer->setData(data);
	m_devices.append(buffer);

	m_devices.append(file);
	file->setParent(this);
	connect(file, SIGNAL(destroyed()), SLOT(deleteLater()));

	data.clear();
	data.append("\r\n--").append(boundary).append("--\r\n");

	buffer = new QBuffer(this);
	buffer->setData(data);
	m_devices.append(buffer);
}
开发者ID:akahan,项目名称:qutim,代码行数:26,代码来源:yandexnaroduploadjob.cpp

示例2: getDirectoryListing

QNetworkReply* ownCloudInfo::getDirectoryListing( const QString& dir )
{
    QNetworkRequest req;
    req.setUrl( QUrl( webdavUrl(_connection) + dir ) );
    req.setRawHeader("Depth", "1");
    QByteArray xml("<?xml version=\"1.0\" ?>\n"
                   "<d:propfind xmlns:d=\"DAV:\">\n"
                   "  <d:prop>\n"
                   "    <d:resourcetype/>\n"
                   "  </d:prop>\n"
                   "</d:propfind>\n");
    QBuffer *buf = new QBuffer;
    buf->setData(xml);
    buf->open(QIODevice::ReadOnly);
    QNetworkReply *reply = davRequest("PROPFIND", req, buf);
    buf->setParent(reply);

    if( reply->error() != QNetworkReply::NoError ) {
        qDebug() << "getting quota: request network error: " << reply->errorString();
    }

    connect( reply, SIGNAL( finished()), SLOT(slotGetDirectoryListingFinished()) );
    connect( reply, SIGNAL( error(QNetworkReply::NetworkError)),
             this, SLOT( slotError(QNetworkReply::NetworkError)));
    return reply;
}
开发者ID:Sc1ence,项目名称:mirall,代码行数:26,代码来源:owncloudinfo.cpp

示例3: defaultTranslator

const KeyboardTranslator* KeyboardTranslatorManager::defaultTranslator()
{
    kDebug() << "Loading default translator from text" << defaultTranslatorText;
    QBuffer textBuffer;
    textBuffer.setData(defaultTranslatorText,strlen(defaultTranslatorText));
    return loadTranslator(&textBuffer,"fallback");
}
开发者ID:Maijin,项目名称:konsole,代码行数:7,代码来源:KeyboardTranslator.cpp

示例4: testPut

    void testPut()
    {
#if defined(USE_QNAM) && QT_VERSION <= QT_VERSION_CHECK(5, 5, 0)
        QSKIP("This test is broken with Qt < 5.5, the fix is 9286a8e5dd97c5d4d7e0ed07a73d4ce7240fdc1d in qtbase");
#endif
        const QString aDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
        QVERIFY(QDir::temp().mkpath(aDir));
        const QString aFile = aDir + QStringLiteral("/accessmanagertest-data");
        const QByteArray content = "We love free software!";
        QBuffer buffer;
        buffer.setData(content);
        QVERIFY(buffer.open(QIODevice::ReadOnly));

        QFile::remove(aFile);

        QNetworkReply *reply = manager()->put(QNetworkRequest(QUrl::fromLocalFile(aFile)), &buffer);
        QSignalSpy spy(reply, SIGNAL(finished()));
        QVERIFY(reply->isRunning());
        QVERIFY(spy.wait());

        QVERIFY(QFile::exists(aFile));
        QFile f(aFile);
        QVERIFY(f.open(QIODevice::ReadOnly));
        QCOMPARE(f.readAll(), content);

        QFile::remove(aFile);
    }
开发者ID:KDE,项目名称:kio,代码行数:27,代码来源:accessmanagertest.cpp

示例5: getQueueRequestCompleted

void NetFlixQueueProxy::getQueueRequestCompleted(int retCode, QString body){
    qDebug() << "queue request completed!!";
    qDebug() << retCode;

    QXmlQuery query;
    QString result;

    QBuffer device;
    device.setData(body.toUtf8());
    device.open(QIODevice::ReadOnly);

    query.bindVariable("netflix_queue",&device);
    query.setQuery(QUrl("qrc:/queries/queue.xq"));
    if (query.isValid())
    {
        if (query.evaluateTo(&result))
            qDebug() << result;
        else
            qDebug() << "Evaluate failed";
    }
    else
        qDebug() << "setQuery Failed.";


}
开发者ID:smandava,项目名称:cuteflix,代码行数:25,代码来源:netflixqueueproxy.cpp

示例6: start

void RequestEtagJob::start()
{
    QNetworkRequest req;
    if (_account && _account->rootEtagChangesNotOnlySubFolderEtags()) {
        // Fixed from 8.1 https://github.com/owncloud/client/issues/3730
        req.setRawHeader("Depth", "0");
    } else {
        // Let's always request all entries inside a directory. There are/were bugs in the server
        // where a root or root-folder ETag is not updated when its contents change. We work around
        // this by concatenating the ETags of the root and its contents.
        req.setRawHeader("Depth", "1");
        // See https://github.com/owncloud/core/issues/5255 and others
    }

    QByteArray xml("<?xml version=\"1.0\" ?>\n"
                   "<d:propfind xmlns:d=\"DAV:\">\n"
                   "  <d:prop>\n"
                   "    <d:getetag/>\n"
                   "  </d:prop>\n"
                   "</d:propfind>\n");
    QBuffer *buf = new QBuffer(this);
    buf->setData(xml);
    buf->open(QIODevice::ReadOnly);
    // assumes ownership
    sendRequest("PROPFIND", makeDavUrl(path()), req, buf);

    if (reply()->error() != QNetworkReply::NoError) {
        qCWarning(lcEtagJob) << "request network error: " << reply()->errorString();
    }
    AbstractNetworkJob::start();
}
开发者ID:uniblockchain,项目名称:client,代码行数:31,代码来源:networkjobs.cpp

示例7: start

void PropfindJob::start()
{
    QList<QByteArray> properties = _properties;

    if (properties.isEmpty()) {
        qWarning() << "Propfind with no properties!";
    }
    QNetworkRequest req;
    req.setRawHeader("Depth", "0");
    QByteArray propStr;
    foreach (const QByteArray &prop, properties) {
        if (prop.contains(':')) {
            int colIdx = prop.lastIndexOf(":");
            propStr += "    <" + prop.mid(colIdx+1) + " xmlns=\"" + prop.left(colIdx) + "\" />\n";
        } else {
            propStr += "    <d:" + prop + " />\n";
        }
    }
    QByteArray xml = "<?xml version=\"1.0\" ?>\n"
                     "<d:propfind xmlns:d=\"DAV:\">\n"
                     "  <d:prop>\n"
                     + propStr +
                     "  </d:prop>\n"
                     "</d:propfind>\n";

    QBuffer *buf = new QBuffer(this);
    buf->setData(xml);
    buf->open(QIODevice::ReadOnly);
    setReply(davRequest("PROPFIND", path(), req, buf));
    buf->setParent(reply());
    setupConnections(reply());
    AbstractNetworkJob::start();
}
开发者ID:alanljj,项目名称:client,代码行数:33,代码来源:networkjobs.cpp

示例8: getImageType

static QString getImageType(const QByteArray& image)
{
#ifndef QXMPP_NO_GUI
    QBuffer buffer;
    buffer.setData(image);
    buffer.open(QIODevice::ReadOnly);
    QString format = QImageReader::imageFormat(&buffer);

    if(format.toUpper() == "PNG")
        return "image/png";
    else if(format.toUpper() == "MNG")
        return "video/x-mng";
    else if(format.toUpper() == "GIF")
        return "image/gif";
    else if(format.toUpper() == "BMP")
        return "image/bmp";
    else if(format.toUpper() == "XPM")
        return "image/x-xpm";
    else if(format.toUpper() == "SVG")
        return "image/svg+xml";
    else if(format.toUpper() == "JPEG")
        return "image/jpeg";
#endif

    return "image/unknown";
}
开发者ID:chloerei,项目名称:qxmpp,代码行数:26,代码来源:QXmppVCard.cpp

示例9: oStream

// +-----------------------------------------------------------
bool f3::LogControl::getLogLevel(const QString &sAppName, QtMsgType &eLevel) const
{
	// Try to lock the shared memory
	if(!m_pSharedMemory->lock())
		return false;

	// Read the map from the shared memory
	QBuffer oBuffer;
	QDataStream oStream(&oBuffer);

	oBuffer.setData((char *) m_pSharedMemory->constData(), m_pSharedMemory->size());
	oBuffer.open(QBuffer::ReadOnly);
	
	QMap<QString, int> mApps;
	oStream >> mApps;

	// Unlock the shared memory before returning
	m_pSharedMemory->unlock();

	// Return the stored value for the application name (if found on the table)
	int iLevel = mApps[sAppName];
	if(iLevel != 0)
	{
		eLevel = (QtMsgType) (iLevel - 1);
		return true;
	}
	else
		return false;
}
开发者ID:luigivieira,项目名称:F3,代码行数:30,代码来源:logcontrol.cpp

示例10: UpdateUserInfo

int CUserInfoXmpp::UpdateUserInfo(const QXmppVCardIq &vCard, QString jid)
{
    //if(!vCard.fullName().isEmpty())
    //    m_szName = vCard.fullName();
    m_szNick = vCard.nickName();
    m_Birthday = vCard.birthday();
    m_szEmail = vCard.email();
    m_szDescription = vCard.description();
    if(!jid.isEmpty() && m_szJid.isEmpty())
        m_szJid = jid;

    //保存头像  
    QByteArray photo = vCard.photo();
    QBuffer buffer;
    buffer.setData(photo);
    buffer.open(QIODevice::ReadOnly);
    QImageReader imageReader(&buffer);
    m_imgPhoto = imageReader.read();
    buffer.close();

    //保存头像到本地  
    QImageWriter imageWriter(CGlobal::Instance()->GetFileUserAvatar(GetId()), "png");
    if(!imageWriter.write(GetPhoto()))
        LOG_MODEL_ERROR("CUserInfo", "Save avater error, %s", imageWriter.errorString().toStdString().c_str());

    return 0;
}
开发者ID:s18leoare,项目名称:rabbitim,代码行数:27,代码来源:UserInfoXmpp.cpp

示例11: open

bool FormWindowEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
    if (Designer::Constants::Internal::debug)
        qDebug() << "FormWindowEditor::open" << fileName;

    auto document = qobject_cast<FormWindowFile *>(textDocument());
    QDesignerFormWindowInterface *form = document->formWindow();
    QTC_ASSERT(form, return false);

    if (fileName.isEmpty())
        return true;

    const QFileInfo fi(fileName);
    const QString absfileName = fi.absoluteFilePath();

    QString contents;
    if (document->read(absfileName, &contents, errorString) != Utils::TextFileFormat::ReadSuccess)
        return false;

    form->setFileName(absfileName);
    const QByteArray contentsBA = contents.toUtf8();
    QBuffer str;
    str.setData(contentsBA);
    str.open(QIODevice::ReadOnly);
    if (!form->setContents(&str, errorString))
        return false;
    form->setDirty(fileName != realFileName);

    document->syncXmlFromFormWindow();
    document->setFilePath(absfileName);
    document->setShouldAutoSave(false);
    document->resourceHandler()->updateResources(true);

    return true;
}
开发者ID:OnlineCop,项目名称:qt-creator,代码行数:35,代码来源:formwindoweditor.cpp

示例12: QBuffer

	QBuffer *createBuffer (const QByteArray &data = "0123456789",
			       QIODevice::OpenMode mode = QIODevice::ReadWrite) {
		QBuffer *buffer = new QBuffer (this);
		buffer->setData (data);
		buffer->open (mode);
		return buffer;
	}
开发者ID:NuriaProject,项目名称:Core,代码行数:7,代码来源:tst_referencedevice.cpp

示例13: path

bool
readStream(POLE::Storage& storage, const char* streampath, QBuffer& buffer)
{
    std::string path(streampath);
    if (storage.isDirectory("PP97_DUALSTORAGE")) {
        qDebug() << "PP97_DUALSTORAGE";
        path = "PP97_DUALSTORAGE" + path;
    }
    POLE::Stream stream(&storage, path);
    if (stream.fail()) {
        qDebug() << "Unable to construct " << streampath << "stream";
        return false;
    }

    QByteArray array;
    array.resize(stream.size());
    unsigned long r = stream.read((unsigned char*)array.data(), stream.size());
    if (r != stream.size()) {
        qDebug() << "Error while reading from " << streampath << "stream";
        return false;
    }
    buffer.setData(array);
    buffer.open(QIODevice::ReadOnly);
    return true;
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:25,代码来源:ParsedPresentation.cpp

示例14: start

void RequestEtagJob::start()
{
    QNetworkRequest req;
    if (path().isEmpty() || path() == QLatin1String("/")) {
        /* For the root directory, we need to query the etags of all the sub directories
         * because, at the time I am writing this comment (Owncloud 5.0.9), the etag of the
         * root directory is not updated when the sub directories changes */
        req.setRawHeader("Depth", "1");
    } else {
        req.setRawHeader("Depth", "0");
    }
    QByteArray xml("<?xml version=\"1.0\" ?>\n"
                   "<d:propfind xmlns:d=\"DAV:\">\n"
                   "  <d:prop>\n"
                   "    <d:getetag/>\n"
                   "  </d:prop>\n"
                   "</d:propfind>\n");
    QBuffer *buf = new QBuffer(this);
    buf->setData(xml);
    buf->open(QIODevice::ReadOnly);
    // assumes ownership
    setReply(davRequest("PROPFIND", path(), req, buf));
    buf->setParent(reply());
    setupConnections(reply());

    if( reply()->error() != QNetworkReply::NoError ) {
        qDebug() << "getting etag: request network error: " << reply()->errorString();
    }
    AbstractNetworkJob::start();
}
开发者ID:Gallaecio,项目名称:vaiven,代码行数:30,代码来源:networkjobs.cpp

示例15: tst_invalidFrames

void tst_WebSocketFrame::tst_invalidFrames()
{
    QFETCH(int, rsv1);
    QFETCH(int, rsv2);
    QFETCH(int, rsv3);
    QFETCH(quint32, mask);
    QFETCH(QWebSocketProtocol::OpCode, opCode);
    QFETCH(bool, isFinal);
    QFETCH(QByteArray, payload);
    QFETCH(QWebSocketProtocol::CloseCode, expectedError);

    FrameHelper helper;
    helper.setRsv1(rsv1);
    helper.setRsv2(rsv2);
    helper.setRsv3(rsv3);
    helper.setMask(mask);
    helper.setOpCode(opCode);
    helper.setFinalFrame(isFinal);
    helper.setPayload(payload);

    QByteArray wireRepresentation = helper.wireRepresentation();
    QBuffer buffer;
    buffer.setData(wireRepresentation);
    buffer.open(QIODevice::ReadOnly);
    QWebSocketFrame frame = QWebSocketFrame::readFrame(&buffer);
    buffer.close();

    QVERIFY(!frame.isValid());
    QCOMPARE(frame.closeCode(), expectedError);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:30,代码来源:tst_websocketframe.cpp


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