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


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

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


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

示例1:

    virtual QIODevice *data(const QUrl &/*url*/)
    {
        if (cachedData.isEmpty())
            return 0;

        QBuffer *buffer = new QBuffer;
        buffer->setData(cachedData);
        buffer->open(QIODevice::ReadOnly);
        return buffer;
    }
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:10,代码来源:tst_qnetworkreply_from_cache.cpp

示例2: Serialize

QByteArray CommandlineOptions::Serialize() const {
  QBuffer buf;
  buf.open(QIODevice::WriteOnly);

  QDataStream s(&buf);
  s << *this;
  buf.close();

  return buf.data();
}
开发者ID:Aceler,项目名称:Clementine,代码行数:10,代码来源:commandlineoptions.cpp

示例3: testSendWithoutSerializer

 void testSendWithoutSerializer() {
     QBuffer dev;
     dev.open(QIODevice::ReadWrite);
     mManager->setSerializer(0);
     mManager->addDevice(&dev);
     // Sending message to dev
     QVERIFY( dev.data().isEmpty() );
     mService->boolSignal(false);
     QVERIFY( dev.data().isEmpty() );
 }
开发者ID:lazyphantom,项目名称:qremotesignal,代码行数:10,代码来源:servicesmanagertests.cpp

示例4: save

void QLCFixtureHead_Test::save()
{
    QLCFixtureHead head;
    head.addChannel(0);
    head.addChannel(1);
    head.addChannel(2);
    head.addChannel(3);

    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly | QIODevice::Text);
    QXmlStreamWriter xmlWriter(&buffer);

    QVERIFY(head.saveXML(&xmlWriter));

    xmlWriter.setDevice(NULL);
    buffer.close();

    buffer.open(QIODevice::ReadOnly | QIODevice::Text);
    QXmlStreamReader xmlReader(&buffer);

    xmlReader.readNextStartElement();

    QCOMPARE(xmlReader.name().toString(), QString("Head"));
    int ch = 0;

    while (xmlReader.readNextStartElement())
    {
        if (xmlReader.name() == "Channel")
        {
            QString chNum = xmlReader.readElementText();
            QVERIFY(chNum.toInt() == 0 || chNum.toInt() == 1 ||
                    chNum.toInt() == 2 || chNum.toInt() == 3);
            ch++;
        }
        else
        {
            QFAIL(QString("Unexpected tag: %1").arg(xmlReader.name().toString()).toUtf8().constData());
            xmlReader.skipCurrentElement();
        }
    }

    QCOMPARE(ch, 4);
}
开发者ID:PML369,项目名称:qlcplus,代码行数:43,代码来源:qlcfixturehead_test.cpp

示例5: sSave

void imageview::sSave()
{
  XSqlQuery newImage;

  if (_mode == cNew)
  {
    if (!__imageview.isNull())
    {
      XSqlQuery imageid("SELECT NEXTVAL('image_image_id_seq') AS _image_id");
      if (imageid.first())
        _imageviewid = imageid.value("_image_id").toInt();
//  ToDo
 
      QImageWriter imageIo;
      QBuffer  imageBuffer;
      QString  imageString;

      imageBuffer.open(QIODevice::ReadWrite);
      imageIo.setDevice(&imageBuffer);
      imageIo.setFormat("PNG");

      if (!imageIo.write(__imageview))
      {
//  ToDo - should issue an error here
        reject();
        return;
      }

      imageBuffer.close();
      imageString = QUUEncode(imageBuffer);

      newImage.prepare( "INSERT INTO image "
                        "(image_id, image_name, image_descrip, image_data) "
                        "VALUES "
                        "(:image_id, :image_name, :image_descrip, :image_data);" );
      newImage.bindValue(":image_id", _imageviewid);
      newImage.bindValue(":image_name", _name->text());
      newImage.bindValue(":image_descrip", _descrip->toPlainText());
      newImage.bindValue(":image_data", imageString);
    }
  }
  else if (_mode == cEdit)
  {
    newImage.prepare( "UPDATE image "
                      "SET image_name=:image_name, image_descrip=:image_descrip "
                      "WHERE (image_id=:image_id);" );
    newImage.bindValue(":image_id", _imageviewid);
    newImage.bindValue(":image_name", _name->text());
    newImage.bindValue(":image_descrip", _descrip->toPlainText());
  }

  newImage.exec();

  done(_imageviewid);
}
开发者ID:Dinesh-Ramakrishnan,项目名称:qt-client,代码行数:55,代码来源:imageview.cpp

示例6: play

void TSoundOutputDeviceImp::play(const TSoundTrackP &st, TINT32 s0, TINT32 s1,
                                 bool loop, bool scrubbing) {
  if (!doSetStreamFormat(st->getFormat())) return;

  MyData *myData = new MyData();

  myData->imp              = shared_from_this();
  myData->totalPacketCount = s1 - s0;
  myData->fileByteCount    = (s1 - s0) * st->getSampleSize();
  myData->entireFileBuffer = new char[myData->fileByteCount];

  memcpy(myData->entireFileBuffer, st->getRawData() + s0 * st->getSampleSize(),
         myData->fileByteCount);

  m_isPlaying       = true;
  myData->isLooping = loop;

  QAudioFormat format;
  QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());

  format.setSampleSize(st->getBitPerSample());
  format.setCodec("audio/pcm");
  format.setChannelCount(st->getChannelCount());
  format.setByteOrder(QAudioFormat::LittleEndian);
  format.setSampleType(st->getFormat().m_signedSample
                           ? QAudioFormat::SignedInt
                           : QAudioFormat::UnSignedInt);
  format.setSampleRate(st->getSampleRate());
  QList<QAudioFormat::Endian> sbos        = info.supportedByteOrders();
  QList<int> sccs                         = info.supportedChannelCounts();
  QList<int> ssrs                         = info.supportedSampleRates();
  QList<QAudioFormat::SampleType> sstypes = info.supportedSampleTypes();
  QList<int> ssss                         = info.supportedSampleSizes();
  QStringList supCodes                    = info.supportedCodecs();
  if (!info.isFormatSupported((format))) {
    format                                 = info.nearestFormat(format);
    int newChannels                        = format.channelCount();
    int newBitsPerSample                   = format.sampleSize();
    int newSampleRate                      = format.sampleRate();
    QAudioFormat::SampleType newSampleType = format.sampleType();
    QAudioFormat::Endian newBo             = format.byteOrder();
  }
  int test = st->getSampleCount() / st->getSampleRate();
  QByteArray *data =
      new QByteArray(myData->entireFileBuffer, myData->fileByteCount);
  QBuffer *newBuffer = new QBuffer;
  newBuffer->setBuffer(data);
  newBuffer->open(QIODevice::ReadOnly);
  newBuffer->seek(0);
  if (m_audioOutput == NULL) {
    m_audioOutput = new QAudioOutput(format, NULL);
  }
  m_audioOutput->start(newBuffer);
  m_audioOutput->setVolume(m_volume);
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:55,代码来源:tsound_qt.cpp

示例7: writeData

    qint64 Request::writeData(const char* data, qint64 maxSize)
    {
        if(m_responseState == WaitingForResponseHeaders)
        {
            m_headerBuffer.append(data, maxSize);
            // We need to buffer the headers, so we can use the STATUS header appropriately
            QBuffer buffer;
            buffer.setData(m_headerBuffer);
            buffer.open(QIODevice::ReadOnly);
            buffer.seek(m_headerBufferPosition);
            while(buffer.canReadLine())
            {
                const QByteArray line = buffer.readLine().trimmed();
                if(line.isEmpty())
                {
                    Q_ASSERT(m_responseHeaders.contains("STATUS"));
                    Q_ASSERT(m_requestHeaders.contains("SERVER_PROTOCOL"));
                    m_responseState = WaitingForResponseBody;
                    const QByteArray status = m_responseHeaders.take("STATUS");
                    m_socket->write(m_requestHeaders.value("SERVER_PROTOCOL"));
                    m_socket->write(" ", 1);
                    m_socket->write(status);
                    m_socket->write("\r\n", 2);

                    //qDebug() << Q_FUNC_INFO << m_requestHeaders << m_responseHeaders;

                    for(
                        HeaderMap::ConstIterator it = m_responseHeaders.constBegin();
                        it != m_responseHeaders.constEnd();
                        ++it
                    )
                    {
                        m_socket->write(it.key());
                        m_socket->write(": ");
                        m_socket->write(it.value());
                        m_socket->write("\r\n");
                    }
                    m_socket->write("\r\n");
                    m_socket->write(buffer.readAll());
                    buffer.close();
                    m_headerBuffer.clear();
                    return maxSize;
                }
                const int lengthOfName = line.indexOf(':');
                const QByteArray name = line.left(lengthOfName);
                const QByteArray value = line.mid(lengthOfName + 2); // ": " after the name == 2 chars
                m_responseHeaders.insertMulti(name, value);
            }
            m_headerBufferPosition = buffer.pos();
            buffer.close();
            return maxSize;
        }
        Q_ASSERT(m_responseState == WaitingForResponseBody);
        return m_socket->write(data, maxSize);
    }
开发者ID:alexey-zayats,项目名称:athletic,代码行数:55,代码来源:httprequest.cpp

示例8: merge

void merge( const QString& newname, const QString& oldname,
	    const QString& resname )
{
    QFile f1(newname);
    if ( !f1.open( IO_ReadOnly) )
	return;

    QFile f2(oldname);
    if ( !f2.open( IO_ReadOnly) )
	return;

    QBuffer fout;
    fout.open(IO_WriteOnly);

    QTextStream in1( &f1 );
    QTextStream in2( &f2 );
    QTextStream out( &fout );

    QString buf1 = in1.readLine().stripWhiteSpace();
    QString buf2 = in2.readLine().stripWhiteSpace();

    Item i1 = getItem( in1, buf1 );
    Item i2 = getItem( in2, buf2 );
    while ( !i1.isNull() || !i2.isNull() ) {
	Status s = compare( i1, i2 );
	if ( s == Equal ) {
	    writemerge(out,i1,i2);
	    i1 = getItem( in1, buf1 );
	    i2 = getItem( in2, buf2 );
	} else if ( s == First ) {
	    writenew( out, i1 );
	    i1 = getItem( in1, buf1 );
	} else if ( s == FirstJunk ) {
	    //solitary comment
	    writejunk( out, i1 );
	    i1 = getItem( in1, buf1 );
	} else if ( s == Second ) {
	    writeold( out, i2 );
	    i2 = getItem( in2, buf2 );
	} else if ( s == SecondJunk ) {
	    //solitary comment
	    writejunk( out, i2 );
	    i2 = getItem( in2, buf2 );
	}
    }

    f1.close();
    f2.close();
    fout.close();
    QFile fileout(resname);
    if ( !fileout.open( IO_WriteOnly | IO_Translate ) )
	return;
    fileout.writeBlock(fout.buffer());
    fileout.close();
}
开发者ID:kthxbyte,项目名称:QT2-Linaro,代码行数:55,代码来源:mergetr.cpp

示例9: sendData

    bool sendData(const T & output)
    {
        QBuffer buffer;
        buffer.open(QBuffer::ReadWrite);

        QDataStream serializer(&buffer);
        serializer << output;
        writeArray = buffer.data();
        emit pulseSendSerialized();
        return true;
    }
开发者ID:EricChen2013,项目名称:openbr,代码行数:11,代码来源:process.cpp

示例10: sendForward

void KMessageClient::sendForward (const QByteArray &msg, const QList <quint32> &clients)
{
  QByteArray sendBuffer;
  QBuffer buffer (&sendBuffer);
  buffer.open (QIODevice::WriteOnly);
  QDataStream stream (&buffer);

  stream << static_cast<quint32>( KMessageServer::REQ_FORWARD ) << clients;
  buffer.QIODevice::write (msg);
  sendServerMessage (sendBuffer);
}
开发者ID:KDE,项目名称:libkdegames,代码行数:11,代码来源:kmessageclient.cpp

示例11: sendBroadcast

void KMessageClient::sendBroadcast (const QByteArray &msg)
{
  QByteArray sendBuffer;
  QBuffer buffer (&sendBuffer);
  buffer.open (QIODevice::WriteOnly);
  QDataStream stream (&buffer);

  stream << static_cast<quint32> ( KMessageServer::REQ_BROADCAST );
  buffer.QIODevice::write (msg);
  sendServerMessage (sendBuffer);
}
开发者ID:KDE,项目名称:libkdegames,代码行数:11,代码来源:kmessageclient.cpp

示例12: defaultTranslator

const KeyboardTranslator* KeyboardTranslatorManager::defaultTranslator()
{
  qDebug() << "Loading default translator from text";
  QBuffer textBuffer;
  textBuffer.setData( defaultTranslatorText, strlen( defaultTranslatorText ) );

  if ( !textBuffer.open( QIODevice::ReadOnly ) )
    return 0;

  return loadTranslator( &textBuffer, "fallback" );
}
开发者ID:AaronGaim,项目名称:QGIS,代码行数:11,代码来源:KeyboardTranslator.cpp

示例13: prepareRequestBuffer

QBuffer* KDSoapClientInterfacePrivate::prepareRequestBuffer(const QString& method, const KDSoapMessage& message, const KDSoapHeaders& headers)
{
    KDSoapMessageWriter msgWriter;
    msgWriter.setMessageNamespace(m_messageNamespace);
    msgWriter.setVersion(m_version);
    const QByteArray data = msgWriter.messageToXml(message, (m_style == KDSoapClientInterface::RPCStyle) ? method : QString(), headers, m_persistentHeaders, m_version);
    QBuffer* buffer = new QBuffer;
    buffer->setData(data);
    buffer->open(QIODevice::ReadOnly);
    return buffer;
}
开发者ID:fstbl,项目名称:KDSoap,代码行数:11,代码来源:KDSoapClientInterface.cpp

示例14: t

QWidget * FLManagerModules::createUI( const QString & n, QObject * connector,
                                      QWidget * parent, const char *name ) {
  QBuffer b;
  b.open( IO_ReadWrite );
  QTextStream t( &b );
  t.setEncoding( QTextStream::Latin1 );
  t << contentCached( n );
  b.reset();
  QWidget * w = QWidgetFactory::create( &b, connector, parent, name );
  return w;
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:11,代码来源:FLManagerModules.cpp

示例15: contentsAsByteArray

QByteArray CopyHelper::contentsAsByteArray() const
{
    QBuffer result;
    result.open(QIODevice::WriteOnly);
    QDataStream os(&result);

    os << m_locations.size();
    foreach (const TextLocation &location, m_locations) {
        os << location.position();
        os << location.length();
    }
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:11,代码来源:copyhelper.cpp


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