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


C++ QVariant::clear方法代码示例

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


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

示例1: read

void SessionManager::read()
{
    QFile f(_sessionsPath);
    QDataStream in;
    QVariant tmp;
    Session *session(0);

    // Opening the saving file
    if (!f.open(QIODevice::ReadOnly))
        return;

    in.setDevice(&f);

    // Reading of all sessions
    while (!in.atEnd())
    {
        session = new Session();

        // Retrieving of the access token
        in >> tmp;

        session->setAccessToken(tmp.toString());
        tmp.clear();

        // Retrieving of the client token
        in >> tmp;

        session->setClientToken(tmp.toString());
        tmp.clear();

        // Retrieving of the player's uuid
        in >> tmp;

        session->setUuid(tmp.toString());
        tmp.clear();

        // Retrieving of the player's username
        in >> tmp;

        session->setName(tmp.toString());
        tmp.clear();

        // Retrieving of the player's legacy
        in >> tmp;

        session->setLegacy(tmp.toBool());
        tmp.clear();
    }

    f.close();
}
开发者ID:rigma,项目名称:EMPLauncher,代码行数:51,代码来源:sessionmanager.cpp

示例2: getTreeValue

QVariant QVariantTree::getTreeValue(const QVariant& root,
                                    const QVariantList& address,
                                    bool* isValid) const
{
    QVariant result = root;
    int indexAddress = 0;
    bool trueValid = true;

    while (trueValid && indexAddress < address.count()) {
        QVariantTreeElementContainer* containerType = NULL;
        QVariant key = address.value(indexAddress++);

        trueValid = typeIsContainer(result.type())
                && (containerType = containerOf(result.type()))
                && containerType->keys(result).contains(key);

        if (trueValid)
            result = containerType->item(result, key);
    }

    if (isValid)
        *isValid = trueValid;
    if (trueValid == false)
        result.clear();

    return result;
}
开发者ID:VaysseB,项目名称:QVariantEditor,代码行数:27,代码来源:qvarianttree.cpp

示例3: proRobotDevice

void CTransaction::proRobotDevice(ROBOT_DATA t_data, QByteArray s_data)
{
    if(changing)
        return;
    int change = 0, i = 0;
    for(i = 0; i < statusDataBuf.count();i++)
    {
        if(t_data.hrg_num == statusDataBuf[i].hrg_num)
        {
            t_data = checkMeaningful(statusDataBuf[i], t_data, change);
            if(change)
            {
                statusDataBuf.removeAt(i);
                i = 0;
            }
            break;
        }
    }
    if(change == 1 ||
            statusDataBuf.count() == i)
    {
        robotStatusData * deviceData= new robotStatusData(t_data);
        QVariantMap deviceMap = toVariantMap(deviceData);
        QVariant deviceJson = toJsonVariant(deviceMap);
        emit uploadRobotDevice(deviceJson);
        deviceMap.clear();
        deviceJson.clear();
        statusDataBuf.append(t_data);
        if(deviceData != NULL)
        {
            delete deviceData;
            deviceData = NULL;
        }
    }
}
开发者ID:YeChenzjg,项目名称:qt_HRG_robot_check,代码行数:35,代码来源:transaction.cpp

示例4: testInitialState

void Ut_DeviceLock::testInitialState()
{
    delete deviceLock;

    qSettingsValue.clear();
    qProcessWaitForFinished = false;
    qProcessExitCode = 0;
    deviceLock = new DeviceLock();

    QCOMPARE(deviceLock->state(), (int)DeviceLock::Unlocked);

    delete deviceLock;
    qSettingsValue = "-1";
    deviceLock = new DeviceLock();

    QCOMPARE(deviceLock->state(), (int)DeviceLock::Unlocked);
    QCOMPARE(qProcessStartProgram, qSettingsValue.toString());
    QCOMPARE(qProcessStartArguments, QStringList() << "--is-set" << "lockcode");

    delete deviceLock;
    qProcessWaitForFinished = true;
    deviceLock = new DeviceLock();

    QCOMPARE(deviceLock->state(), (int)DeviceLock::Unlocked);

    delete deviceLock;
    qProcessExitCode = 1;
    deviceLock = new DeviceLock();

    QCOMPARE(deviceLock->state(), (int)DeviceLock::Unlocked);
}
开发者ID:SfietKonstantin,项目名称:lipstick,代码行数:31,代码来源:ut_devicelock.cpp

示例5: initAttributes

void QgsFeature::initAttributes( int fieldCount )
{
  mAttributes.resize( fieldCount );
  QVariant* ptr = mAttributes.data();
  for ( int i = 0; i < fieldCount; ++i, ++ptr )
    ptr->clear();
}
开发者ID:Hardysong,项目名称:Quantum-GIS,代码行数:7,代码来源:qgsfeature.cpp

示例6: readValue

toQValue mysqlQuery::readValue(void)
{
    if (!Query)
        throw toConnection::exception(QString::fromLatin1("Fetching from not executed query"));
    if (EOQ)
        throw toConnection::exception(QString::fromLatin1("Tried to read past end of query"));

    LockingPtr<QSqlDatabase> ptr(Connection->Connection, Connection->Lock);
    QVariant retval;
    {
        retval = Query->value(CurrentColumn);
        if (Query->isNull(CurrentColumn))
            retval.clear();
    }

    CurrentColumn++;
    if (CurrentColumn == (unsigned int) Record.count())
    {
        CurrentColumn = 0;
        EOQ = !Query->next();
    }
    if (EOQ)
    {
        delete Query;
        Query = NULL;
    }

    return toQValue::fromVariant(retval);
}
开发者ID:dieface,项目名称:tora,代码行数:29,代码来源:toqmysqlquery.cpp

示例7: parseReplyDataVariant

QVariant ContentItemInterfacePrivate::parseReplyDataVariant(const QByteArray &replyData, bool *ok)
{
    QVariant parsed;

#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
    QJson::Parser jsonParser;
    parsed = jsonParser.parse(replyData, ok);
    if (!*ok) {
        qWarning() << Q_FUNC_INFO << "Error parsing JSON file:" << jsonParser.errorString()
                   << "at" << jsonParser.errorLine();
    }
#else
    QJsonParseError jsonError;
    QJsonDocument jsonDocument = QJsonDocument::fromJson(replyData, &jsonError);
    *ok = !jsonDocument.isEmpty();
    if (!*ok) {
        qWarning() << Q_FUNC_INFO << "Error parsing JSON file:" << jsonError.errorString()
                   << "at" << jsonError.offset;
    }
    parsed = jsonDocument.toVariant();
#endif

    if (!*ok) {
        parsed.clear();
    }

    return parsed;
}
开发者ID:SfietKonstantin,项目名称:nemo-qml-plugin-social,代码行数:28,代码来源:contentiteminterface.cpp

示例8: internalDelTreeValue

QVariant QVariantTree::internalDelTreeValue(const QVariant& root,
                                    const QVariantList& address,
                                    bool* isValid) const
{
    QVariant result = root;
    bool trueValid = true;

    if (address.isEmpty())
        result.clear(); // if no address -> invalid
    else if (address.count() == 1) {
        QVariantTreeElementContainer* containerType = containerOf(result.type());
        if (containerType == NULL)
            trueValid = false;
        else
            result = containerType->delItem(result, address.first());
    }
    else {
        QVariantTreeElementContainer* containerType = containerOf(result.type());
        if (containerType && containerType->keys(result).contains(address.first())) {
            result = containerType->item(result, address.first());
            result = internalDelTreeValue(result, address.mid(1));
            result = containerType->setItem(root, address.first(), result);
        }
        else
            trueValid = false;
    }

    if (isValid)
        *isValid = trueValid;

    return result;
}
开发者ID:VaysseB,项目名称:QVariantEditor,代码行数:32,代码来源:qvarianttree.cpp

示例9: testReader

static void testReader () {
  do {

  QFile fl("one.json");
  if (!fl.open(QIODevice::ReadOnly)) {
    fprintf(stderr, "ERROR: can't open input file!\n");
    return;
  }

  const uchar *fmap = (const uchar *)(fl.map(0, fl.size()));
  int len = fl.size();
  const uchar *sj = K8JSON::skipBlanks(fmap, &len);
  if (!sj) {
    fprintf(stderr, "ERROR: invalid JSON file!\n");
    break;
  }
  uchar qch = *sj;
  if (qch != '[' && qch != '{') {
    fprintf(stderr, "ERROR: invalid JSON file!\n");
    break;
  }

  int cnt = 0;
  QTime st;
  st.start();

  QVariant val;
  while (sj) {
    //int ofs = sj-fmap;
    //fprintf(stderr, "0x%08x  %i\n", ofs, cnt);
    for (;;) {
      if (!(sj = K8JSON::skipBlanks(sj, &len))) break;
      if (*sj != ',') break;
      sj++; len--;
    }
    val.clear();
    sj = K8JSON::parseRecord(val, sj, &len);
    if (!sj) {
      //fprintf(stderr, "ERROR: invalid JSON file!\n");
      break;
    }
    qDebug() << val;
    QByteArray bo;
    if (!K8JSON::generate(bo, val)) {
      fprintf(stderr, "ERROR: can't generate JSON!\n");
      break;
    }
    qDebug() << bo;
    cnt++;
  }
  qDebug() << "time taken (ms):" << st.elapsed();
  fprintf(stdout, "%i messages found.\n", cnt);


  } while (0);
}
开发者ID:Eagly-messenger,项目名称:Plugin-VK,代码行数:56,代码来源:test.cpp

示例10: Detach_IOTA

int IOTA_Tool_UtilityClass::Detach_IOTA(QVariantHash *args)
{
//init the context for this function
to->enterFunction();

//unpack input arguments begin
QVariantHash EASYTEST_FUNCTION_ARGUMENTS =  (*args);
QVariantHash EASYTEST_FUNCTION_ARGUMENTS_TEMPORARY = EASYTEST_FUNCTION_ARGUMENTS;
PSessionRunner *IOTATelnetSession = 0;
if ( (*args)["IOTATelnetSession"].toString().isEmpty()) { IOTATelnetSession = to->createSessionRunner("IOTATelnetSession", QVariant("Telnet(IOTATelnetSession)"), QStringList()<<"defaultResponseMapping.torm"); if (IOTATelnetSession == 0) return -1;}
if (!(*args)["IOTATelnetSession"].toString().isEmpty()) { IOTATelnetSession = to->createSessionRunner("IOTATelnetSession", (*args)["IOTATelnetSession"], QStringList()); if (IOTATelnetSession == 0) return -1;}
//unpack input arguments end

//function local variables begin

//function local variables end

//function common variable begin
int error = 0; // error code for each step
int functionErrorCode = 0; //error code for the whole function
int EASYTEST_HOW_MANY_TIMES_WE_CALLED_FAILCASE_IN_THIS_FUNCTION = 0;
int EASYTEST_HOW_MANY_TIMES_WE_ENTERED_CLEANUP_SECTION = 0;
//function common variable end

//steps begin
{
//step begin {f611b80c-fe02-433d-aab2-6779cdb9af48}
ServiceCommand serviceCommandf611b80cfe02433daab26779cdb9af48;
serviceCommandf611b80cfe02433daab26779cdb9af48.commandStarted("call", "{f611b80c-fe02-433d-aab2-6779cdb9af48}", " ");
serviceCommandf611b80cfe02433daab26779cdb9af48["I_Do_Not_Have_Option_Name"] = QString("-function SCG_Automation/Regression/Framework/Utility/Common_Tool_Utility::DetachScreenSessionViaTelnet -TelnetSession %1").arg("$IOTATelnetSession");
QVariantHash argsf611b80cfe02433daab26779cdb9af48;
argsf611b80cfe02433daab26779cdb9af48["EASYTEST_TC_BASE_NAME"] = args->value("EASYTEST_TC_BASE_NAME");
argsf611b80cfe02433daab26779cdb9af48["TelnetSession"].setValue(reinterpret_cast<qlonglong>(IOTATelnetSession));
error = to->callRemoteFunction(serviceCommandf611b80cfe02433daab26779cdb9af48, QString("SCG_Automation/Regression/Framework/Utility/Common_Tool_Utility::DetachScreenSessionViaTelnet"), args, &argsf611b80cfe02433daab26779cdb9af48);
IOTATelnetSession = reinterpret_cast<PSessionRunner *>(static_cast<quintptr>(argsf611b80cfe02433daab26779cdb9af48["TelnetSession"].toInt()));
serviceCommandf611b80cfe02433daab26779cdb9af48.commandFinished(error);
to->log(serviceCommandf611b80cfe02433daab26779cdb9af48);
to->updateTcExecutionStatus(error, functionErrorCode);
{QHashIterator<QString, QVariant> iter(argsf611b80cfe02433daab26779cdb9af48);
while (iter.hasNext()){iter.next();QVariant v = iter.value();v.clear();}
argsf611b80cfe02433daab26779cdb9af48.clear();}
//step end {f611b80c-fe02-433d-aab2-6779cdb9af48}
}
//steps end


goto EASYTEST_GOTO_LABEL_CLEANUP_SECTION;
EASYTEST_GOTO_LABEL_CLEANUP_SECTION:
if (++EASYTEST_HOW_MANY_TIMES_WE_ENTERED_CLEANUP_SECTION > 1) {goto EASYTEST_GOTO_LABEL_LEAVING_FUNCTION;}

// cleanup before leaving this function
EASYTEST_GOTO_LABEL_LEAVING_FUNCTION:
to->leaveFunction();
if (EASYTEST_HOW_MANY_TIMES_WE_CALLED_FAILCASE_IN_THIS_FUNCTION > 0) { functionErrorCode = -1;}
return functionErrorCode;
}
开发者ID:frankjiao,项目名称:script,代码行数:56,代码来源:IOTA_Tool_Utility.cpp

示例11: metaData

QVariant QMDEGalleryResultSet::metaData(int key) const
{
    QVariant retval;

    if( !m_isValid ) {
        retval.clear();
        return retval;
    }

    CMdEObject *item = m_itemArray[m_cursorPosition];
    if (item) {
        TRAPD( err, QDocumentGalleryMDSUtility::GetMetaDataFieldL( item, retval, key ) );
        if (err) {
            retval.clear();
        }
    }

    return retval;
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例12: getSetting

//
// Function to return a setting as a QVariant
QVariant Settings::getSetting(const QString& group, const QString& elem)
{
	QVariant v;
	v.clear();
	
	settings->beginGroup(group);
	v = settings->value(elem);
	settings->endGroup();
	
	return v;	
}
开发者ID:andrew-bibb,项目名称:mbmp,代码行数:13,代码来源:settings.cpp

示例13: clear

void QPlaceSearchRequestPrivate::clear()
{
    limit = -1;
    searchTerm.clear();
    categories.clear();
    searchArea = QGeoShape();
    recommendationId.clear();
    visibilityScope = QLocation::UnspecifiedVisibility;
    relevanceHint = QPlaceSearchRequest::UnspecifiedHint;
    searchContext.clear();
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:11,代码来源:qplacesearchrequest.cpp

示例14: testReaderAll

static void testReaderAll () {
  do {

  QFile fl("onex.json");
  if (!fl.open(QIODevice::ReadOnly)) {
    fprintf(stderr, "ERROR: can't open input file!\n");
    return;
  }

  const uchar *fmap = (const uchar *)(fl.map(0, fl.size()));
  int len = fl.size();
  const uchar *sj = K8JSON::skipBlanks(fmap, &len);
  if (!sj) {
    fprintf(stderr, "ERROR: invalid JSON file!\n");
    break;
  }
  uchar qch = *sj;
  if (qch != '[' && qch != '{') {
    fprintf(stderr, "ERROR: invalid JSON file!\n");
    break;
  }
  sj++; len--;
  qch = (qch=='{' ? '}' : ']');

  int cnt = 0;
  QTime st;
  st.start();

  QVariant val;
  while (sj) {
    //int ofs = sj-fmap;
    //fprintf(stderr, "0x%08x  %i\n", ofs, cnt);
    sj = K8JSON::skipBlanks(sj, &len);
    if (len < 2 || (sj && *sj == qch)) break;
    if ((cnt && *sj != ',') || (!cnt && *sj == ',')) {
      fprintf(stderr, "ERROR: invalid JSON file (delimiter)!\n");
      break;
    }
    if (*sj == ',') { sj++; len--; }
    val.clear();
    sj = K8JSON::parseRecord(val, sj, &len);
    if (!sj) {
      fprintf(stderr, "ERROR: invalid JSON file!\n");
      break;
    }
    //qDebug() << val;
    cnt++;
  }
  qDebug() << "time taken (ms):" << st.elapsed();
  fprintf(stdout, "%i messages found.\n", cnt);

  } while (0);
}
开发者ID:Eagly-messenger,项目名称:Plugin-VK,代码行数:53,代码来源:test.cpp

示例15: unpackDataValue

void unpackDataValue(DataValue *value, QVariant_ *var)
{
    QVariant *qvar = reinterpret_cast<QVariant *>(var);
    switch (value->dataType) {
    case DTString:
        *qvar = QString::fromUtf8(*(char **)value->data, value->len);
        break;
    case DTBool:
        *qvar = bool(*(char *)(value->data) != 0);
        break;
    case DTInt64:
        *qvar = *(qint64*)(value->data);
        break;
    case DTInt32:
        *qvar = *(qint32*)(value->data);
        break;
    case DTUint64:
        *qvar = *(quint64*)(value->data);
        break;
    case DTUint32:
        *qvar = *(quint32*)(value->data);
        break;
    case DTFloat64:
        *qvar = *(double*)(value->data);
        break;
    case DTFloat32:
        *qvar = *(float*)(value->data);
        break;
    case DTColor:
        *qvar = QColor::fromRgba(*(QRgb*)(value->data));
        break;
    case DTVariantList:
        *qvar = **(QVariantList**)(value->data);
        delete *(QVariantList**)(value->data);
        break;
    case DTObject:
        qvar->setValue(*(QObject**)(value->data));
        break;
    case DTInvalid:
        // null would be more natural, but an invalid variant means
        // it has proper semantics when dealing with non-qml qt code.
        //qvar->setValue(QJSValue(QJSValue::NullValue));
        qvar->clear();
        break;
    default:
        panicf("unknown data type: %d", value->dataType);
        break;
    }
}
开发者ID:chai2010,项目名称:qml,代码行数:49,代码来源:goqml.cpp


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