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


C++ QDataStream::setVersion方法代码示例

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


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

示例1: chargerFichier

void AddressBook::chargerFichier() {
    QString nomFichier = QFileDialog::getOpenFileName(this,
                                                      tr ("Charger depuis un fichier"),
                                                      "",
                                                      tr ("Carnet d'adresse (*.abk);;Tous les fichiers (*)"));
    if (nomFichier.isEmpty())
        return;
    else {
        QFile fichier (nomFichier);
        if (!fichier.open(QIODevice::ReadOnly)) {
            QMessageBox::information(this,
                                     tr ("Erreur de chargement"),
                                     fichier.errorString());
            return;
        }
        QDataStream in (&fichier);
        in.setVersion(QDataStream::Qt_4_7);
        listeContacts.empty();
        in >> listeContacts;
        if (listeContacts.isEmpty()) {
            QMessageBox::information (this ,
                                      tr ("Pas de contacts"),
                                      tr ("Aucun contact à importer dans le fichier"));
        } else {
            QMap<QString , QString>::iterator i = listeContacts.begin();
            nomLineEdit->setText(i.key());
            adresseTextEdit->setText(i.value());
        }

    }
    updateInterface(NavigationMode);
}
开发者ID:sangfroid70,项目名称:carnet_adresse,代码行数:32,代码来源:addressbook.cpp

示例2: onReadyRead

void NetWorkClient::onReadyRead()
{
    QDataStream in ( this );
    in.setVersion(QDataStream::Qt_4_0); // Для совместимости с серверной частью

    while (this->bytesAvailable() > 0){
        if (packetSize == -1) {
            //Определим количество байт доступных для чтения min >= 8 byte
            if( (PACKET_SIZE) this->bytesAvailable() < (PACKET_SIZE) sizeof(packetSize) ){
                return;
            }            
            in >> packetSize;//Читаем размер пакета
        }
        //Проверим что в сокет пришел весь пакет а не его огрызки
        if (this->bytesAvailable() < packetSize){
            return;
        }
        //Сбросим размер пакета, для обработки следующего
        packetSize = -1;
        // Прочтем тип сообщения
        int m_Type;
        in >> m_Type;

        //Прочтем само сообщение
        QByteArray data;
        in >> data;
        Message message( this );
        message.setType((MessageType) m_Type);
        message.setMessageData( data );
        // Отправка сообщения
        emit reciveMessage( message );
    }
}
开发者ID:sobiron236,项目名称:zarya-print,代码行数:33,代码来源:networkclient.cpp

示例3: qt_init

// Called before first plot after a set term command.
void qt_init()
{
	// Start the QtGnuplotApplication if not already started
	if (qt_initialized)
		return;

	// Fork the GUI if necessary
	int argc = 0;
	pid_t pid = 0;
	pid = fork();
	if (pid < 0)
		fprintf(stderr, "Forking error\n");
	else if (pid == 0) // Child: start the GUI
	{
		signal(SIGINT, SIG_IGN); // Do not listen to SIGINT signals anymore
		QtGnuplotApplication application(argc, (char**)( NULL));
		application.exec();
		exit(0);
	}

	// Parent: create a QApplication without event loop for QObject's that need it
	QApplication* application = new QApplication(argc, (char**)( NULL));

	// Init state variables
	qt_localServerName = "qtgnuplot" + QString::number(pid);
	qt_out.setVersion(QDataStream::Qt_4_4);
	qt_initialized = true;
	GP_ATEXIT(qt_atexit);

	// The creation of a QApplication mangled our locale settings
#ifdef HAVE_LOCALE_H
	setlocale(LC_NUMERIC, "C");
	setlocale(LC_TIME, current_locale);
#endif
}
开发者ID:zsx,项目名称:gnuplot,代码行数:36,代码来源:qt_term.cpp

示例4: onIpcData

void ScProcess::onIpcData()
{
    mIpcData.append(mIpcSocket->readAll());

    while (mIpcData.size()) {
        QBuffer receivedData ( &mIpcData );
        receivedData.open ( QIODevice::ReadOnly );

        QDataStream in ( &receivedData );
        in.setVersion ( QDataStream::Qt_4_6 );
        QString selector, message;
        in >> selector;
        if ( in.status() != QDataStream::Ok )
            return;

        in >> message;
        if ( in.status() != QDataStream::Ok )
            return;

        mIpcData.remove ( 0, receivedData.pos() );

        onResponse(selector, message);

        emit response(selector, message);
    }
}
开发者ID:DarienBrito,项目名称:supercollider,代码行数:26,代码来源:sc_process.cpp

示例5: out

ContestantConnection::ContestantConnection ( ServerNetwork* sn, QTcpSocket* socket ) : QObject ( sn ) {
	m_snet = sn;
	m_answer_capable = true;
	m_hdr = NULL;
	m_authenticated = false;
	m_socket = socket;
	connect ( m_socket, SIGNAL ( error ( QAbstractSocket::SocketError ) ),
	          this, SLOT ( error ( QAbstractSocket::SocketError ) ) );
	connect ( m_socket, SIGNAL ( readyRead() ), this, SLOT ( ready() ) );
	connect ( m_socket, SIGNAL ( disconnected() ), this, SLOT ( disconnected() ) );
	// reply to client of the now established connection
	QByteArray block;
	QDataStream out ( &block, QIODevice::WriteOnly );
	out.setVersion ( QDataStream::Qt_4_5 );
	// construct the header
	p_header hdr;
	hdr.length = sizeof ( ushort );
	hdr.command = NET_CONNECTION_RESULT;

	out.writeRawData ( ( const char* ) &hdr, sizeof ( p_header ) );
	out << ( ushort ) true;

	m_socket->write ( block );
	m_socket->flush();

	m_qnum = m_snet->getQNumber();
	m_qtime = m_snet->getQTime();
	m_qstatus = m_snet->getQStatus();
}
开发者ID:trigger-happy,项目名称:Cerberus,代码行数:29,代码来源:contestant_connection.cpp

示例6: ready

void TempConnection::ready()
{
        QDataStream in ( m_socket );
        in.setVersion ( QDataStream::Qt_4_5 );
        if ( m_hdr == NULL ) {
                if ( m_socket->bytesAvailable() < ( int ) sizeof ( p_header ) ) {
                        return;
                }
                m_hdr = new p_header;
                in.readRawData ( ( char* ) m_hdr, sizeof ( p_header ) );
                //check the packet
                if ( strcmp ( ( const char* ) m_hdr->ident.data, "CERB" ) != 0 ) {
                        // bad packet, do something here
                        return;
                }
                //check the version
                if ( !is_proto_current ( m_hdr->ver ) ) {
                        // the version is not the same, do something here
                }
        }
        if ( m_socket->bytesAvailable() < m_hdr->length ) {
                return;
        }

        if ( m_hdr->command == NET_INITIATE_CONNECTION ) {
                uchar client_type;
                in >> client_type;
                emit newClient ( this, static_cast<CLIENT_ID> ( client_type ) );
        } else {
开发者ID:jlgo172003,项目名称:Cerberus,代码行数:29,代码来源:temp_connection.cpp

示例7: saveParams

void Advanced::saveParams()
{
    QFileDialog dialogRaster;
        dialogRaster.setAcceptMode(QFileDialog::AcceptSave);
        dialogRaster.setFileMode(QFileDialog::AnyFile);
        dialogRaster.setDirectory(QDir::toNativeSeparators(QCoreApplication::applicationDirPath()));
        dialogRaster.setFilter(QDir::Files);
        dialogRaster.setWindowTitle("Save Projection Parameters");
        dialogRaster.setNameFilter("Config files (*.config)");
        dialogRaster.exec();

        QString filename = dialogRaster.selectedFiles().first();
        if (filename.isEmpty())
            return;
        else
        {
            QFile file(filename);
            if (!file.open(QIODevice::WriteOnly))
            {
                QMessageBox::information(this, tr("Unable to open file"), file.errorString());
                return;
            }

            QDataStream out (&file);
            out.setVersion(12);
            //out << ;//Write DATA here
        }
}
开发者ID:stramel,项目名称:drasterblaster,代码行数:28,代码来源:advanced.cpp

示例8: save

bool Serialization::save(std::multiset<Event *, Cmp_event_day> &events)
{
    //Save file to disk
    QFile file("events.txt");
    if(!file.open(QIODevice::WriteOnly))
    {
        qDebug() << "Could not open file";
        return false;
    }

    //create output stream
    QDataStream out (&file);
    //set output version
    out.setVersion(QDataStream::Qt_4_8);

    //iteration
    std::multiset<Event *>::iterator it;
    for ( it=events.begin() ; it != events.end(); it++ )
        out << **it;

    //Finito! flush the stream to the file and close
    file.flush();
    file.close();
    return true;
}
开发者ID:CDargis,项目名称:Roto-Cal,代码行数:25,代码来源:serialization.cpp

示例9: sendAllData

//отправление данных по всем кораблям
void MyServer::sendAllData(){
    //deleteShipButton->setEnabled(false);

    QByteArray block;
    QDataStream out (&block, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_5_5);

    out << quint16(0) << logNumbersOfRemovedShips.size();       //количество удаленных кораблей
    for(int k = 0; k < logNumbersOfRemovedShips.size(); k++){   //номер лога удаленного корабля
        out << logNumbersOfRemovedShips.at(k);                  //
    }

    logNumbersOfRemovedShips.clear();

    out << shipCounter;     //количество существующих на сервере кораблей

    //для всех кораблей
    for(int i=0; i < shipCounter; i++){

        generateData(shipList.at(i));   //генерируем новые данные

        out << shipList.at(i)->id
            << shipList.at(i)->startX
            << shipList.at(i)->startY
            << shipList.at(i)->courseAngle
            << shipList.at(i)->speed
            << shipList.at(i)->viewAngle
            << shipList.at(i)->viewLength
            << shipList.at(i)->pathLength
            << shipList.at(i)->time;



        QTextEdit *te = (QTextEdit*)txtStack->widget(i);        //получение указателя на лог текущего корабля
        te->append(QString("Id: %1").arg(shipList.at(i)->id+1));//вывод сгенерированной информации в лог

        if(shipList.at(i)->isNew){
            te->append(QString("Start X: %1\nStart Y: %2")
                       .arg(shipList.at(i)->startX)
                       .arg(shipList.at(i)->startY));
        }



        te->append(QString("Course angle: %1 deg\nSpeed: %2\nView angle: %3 deg\nViewLength: %4\nPath length: %5 m\nTime: %6 sec\n")
                       .arg(shipList.at(i)->courseAngle)
                       .arg(shipList.at(i)->speed).arg(shipList.at(i)->viewAngle)
                       .arg(shipList.at(i)->viewLength).arg(shipList.at(i)->pathLength).arg(shipList.at(i)->time/1000.0f));

        shipList.at(i)->isNew=0;
    }

    out.device()->seek(0);  //переход в начало блока
    out<<quint16(block.size()-sizeof(quint16)); //размер блока данных
    if(isClientConnected) socket->write(block);   //посылка клиенту, если он подключен
    block.clear();          //очистка используемого блока

    if(!deleteShipButton->isEnabled()&& shipCounter>0) deleteShipButton->setEnabled(true);
}
开发者ID:SimpleName,项目名称:practice,代码行数:60,代码来源:myserver.cpp

示例10: readData

/*数据读取函数*/
void ClientSocket::readData()
{
    QDataStream in;
    in.setDevice(this);
    in.setVersion(QDataStream::Qt_4_7);

    QVariant v;
    AllAnswers allAnswers;
    Student student;
    /*如果还没有块大小信息则尝试去读取*/
    if(_totalBytes == 0)
    {
        /*如果缓存区中可读数据的大小小于块大小信息的大小则返回*/
        if(this->bytesAvailable()<sizeof(qint32))
            return;
        /*写入块大小信息*/
        in >> _totalBytes;
    }
    /*如果缓存区可读信息的大小小于块大小则返回*/
    if(this->bytesAvailable()<_totalBytes)
        return;
    /*反之则说明完整的数据块已经到达缓存区,可以开始读取*/
    /*写入信息类型*/
    in >> _messageType;
    /*根据信息类型写入信息内容*/
    switch(_messageType)
    {
    case MSG_NEWCONNECT:
        in >> student;
        v.setValue(student);
        break;
    case MSG_LOGIN:
        in >> student;
        student.setSockDescriptor(this->socketDescriptor());
        v.setValue(student);
        break;
    case MSG_GETPAPER:
        in >> student;
        v.setValue(student);
        break;
    case MSG_ANSWER:
        in >> allAnswers;
        v.setValue(allAnswers);
        break;
    case MSG_ANSWERSINGLE:
        in >> allAnswers;
        v.setValue(allAnswers);
        break;
    }
    /*将块大小信息重置为0,准备接收下一个数据块*/
    _totalBytes = 0;
    /*发送信息到达信号*/
    emit this->messageArrive(this->socketDescriptor(),_messageType,v);
}
开发者ID:AlanForeverAi,项目名称:Exams,代码行数:55,代码来源:server.cpp

示例11: saveFeatures

void saveFeatures(QDataStream &outstream, const QString &extractorName,
                  const QStringList &extractorArgs, const int &extractorSize,
                  const QVector<LabelledData> &data)
{
    outstream.setVersion(QDataStream::Qt_4_6);
    outstream.setByteOrder(QDataStream::BigEndian);

    int size = sizeof(nnreal);
    outstream << size;
    outstream << extractorName;
    outstream << extractorArgs;
    outstream << extractorSize;
    outstream << data;
}
开发者ID:janisozaur,项目名称:ro,代码行数:14,代码来源:main.cpp

示例12: savePaperSetRelationFile

//保存各试卷关系信息
int CardDoc::savePaperSetRelationFile(int courseIndex, QString fileName)
{
	QList<QString> setId;
	QList<int> dpi;
	QList<int> pageCount;
	QList<QString> pageId;
	QList<bool> isPositive;

	vector<PaperSet>::iterator iter = m_course.at(courseIndex).set.begin();

	for (; iter != m_course.at(courseIndex).set.end(); ++iter)
	{
		setId.push_back(iter->setId);
		dpi.push_back(iter->dpi);
		pageCount.push_back(iter->page.size());

		vector<PaperPage>::iterator iter2 = iter->page.begin();

		for (; iter2 != iter->page.end(); ++iter2)
		{
			pageId.push_back(iter2->pageId);
			isPositive.push_back(iter2->isPositive);
		}
	}

	QFile file(fileName);

	if (!file.open(QIODevice::WriteOnly))
	{
		return 0;
	}

	QDataStream data;
	data.setDevice(&file);
	data.setVersion(QDataStream::Qt_4_8);

	//输出试卷关系信息
	data << quint32(PAPERSET_MAGIC_NUM) << quint32(VERSION) 
		 << m_acType << m_course.at(courseIndex).courseName
		 << m_course.at(courseIndex).set.size() << setId << dpi
		 << pageCount << pageId << isPositive;

	if (file.isOpen())
	{
		file.close();
	}
	return 1;
}
开发者ID:billhhh,项目名称:whcode_organizer,代码行数:49,代码来源:CardDoc.cpp

示例13: ensureSerializesCorrectly

void ensureSerializesCorrectly(const QPicture &picture, QDataStream::Version version)
 {
    QDataStream stream;

    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly);
    stream.setDevice(&buffer);
    stream.setVersion(version);
    stream << picture;
    buffer.close();

    buffer.open(QIODevice::ReadOnly);
    QPicture readpicture;
    stream >> readpicture;
    QVERIFY2(memcmp(picture.data(), readpicture.data(), picture.size()) == 0,
        qPrintable(QString::fromLatin1("Picture data does not compare equal for QDataStream version %1").arg(version)));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:17,代码来源:tst_qpicture.cpp

示例14: Login

bool PackageReader::Login()
{
    QDataStream socketStream;
    socketStream.setVersion(QDataStream::Qt_4_8);
    socketStream.setDevice(s);
    struct User *user;
    int nameLen,passwdLen;
    QString name,passwd;
    socketStream>>nameLen;
    if(nameLen<0||nameLen>MAX_STR_LEN)
    {
        socketStream<<FAULT;
        return 0;
    }
    name.resize(nameLen);
    socketStream>>name;
    socketStream>>passwdLen;
    if(passwdLen<0||passwdLen>MAX_STR_LEN)
    {
        socketStream<<FAULT;
        return 0;
    }
    passwd.resize(passwdLen);
    socketStream>>passwd;
    qDebug()<<"user name"<<name<<"passwd:"<<passwd;
    /*bala
     *bala
     *bala
     */
    user = new struct User;
    user->name=name;
    user->add=s->peerAddress();
    user->online=1;
    user->port=s->peerPort();
    qDebug()<<user->name;
    if(-1==l->Insert(user))
    {
        delete user;
        socketStream<<FAULT;
        return 0;
    }
    socketStream<<SUCCEED;
    return 1;

}
开发者ID:k568613637,项目名称:Game,代码行数:45,代码来源:packagereader.cpp

示例15: commandReceived

void Analyzer::commandReceived(const QByteArray &commandline)
{
    QDataStream in (commandline);
    in.setVersion(QDataStream::Qt_4_7);
    uchar command;

    in >> command;

    if (channelCommands.contains(command)) {
        qint32 chanid;
        in >> chanid;

        /* Because we're giving a pointer to a locally declared instance, this connection must
           be a DIRECT connection and never go in Queued mode. If you want queued mode, find another
           way to transfer the data */
        emit channelCommandReceived(command, chanid, &in);
        return;
    }
开发者ID:Antar1011,项目名称:pokemon-online-1.0.53,代码行数:18,代码来源:analyze.cpp


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