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


C++ QByteArray::toUInt方法代码示例

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


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

示例1: updateRtc

void NeoControl::updateRtc()
{
    if(screen != ScreenRtc)
        return;

    QDateTime rtcNow = Qtopia::rtcNow();
    QString rtcDate = Qtopia::readFile("/sys/class/rtc/rtc0/date").trimmed();
    QString rtcTime = Qtopia::readFile("/sys/class/rtc/rtc0/time").trimmed();

    QByteArray wakealarmStr = Qtopia::readFile("/sys/class/rtc/rtc0/wakealarm").trimmed();
    QString alarmStr;
    if(wakealarmStr.isEmpty()) {
        alarmStr = tr("not set");
    } else {
        uint wakealarmSecs = wakealarmStr.toUInt();
        QDateTime wakealarmDt = QDateTime::fromTime_t(wakealarmSecs);
        alarmStr = wakealarmDt.toString();
    }

    label->setText(QString(tr("RTC (Real time clock)\n\nDate: %1\nTime: %2\nLocal: %3\nAlarm: %4"))
                   .arg(rtcDate)
                   .arg(rtcTime)
                   .arg(rtcNow.toString())
                   .arg(alarmStr));

    QTimer::singleShot(1000, this, SLOT(updateRtc()));
}
开发者ID:Artox,项目名称:qtmoko,代码行数:27,代码来源:neocontrol.cpp

示例2: on_btnNextStep_clicked

void ForgetPwdVerifyPage::on_btnNextStep_clicked()
{
    if(editValidate->text().length() != 6){
        QString strText = tr("请输入6位验证码");
        hintMsgPage->setText(strText);
        hintMsgPage->show();

        editValidate->setFocus();
        return;
    }

    QString strValidationCode = editValidate->text().trimmed();
    QByteArray byteValidationCode = strValidationCode.toLatin1();
    verifyCode = byteValidationCode.toUInt();

    AssemblyData assemblyData;
    assemblyData.append(verifyCode);
    char* data = assemblyData.getAssemblyData();
    quint16 dataLen = assemblyData.getAssemblyDataLen();
    emit readyRead(CommandCode::FORGET_PASSWORD_VERIFY, data, dataLen);

    if(loadingPage == NULL){
        loadingPage = new LoadingPage(this);
        loadingPage->show();
    }
}
开发者ID:LinLinYi,项目名称:kirogi,代码行数:26,代码来源:ForgetPwdVerifyPage.cpp

示例3: memcpy

/**@brief convert QString to int (4 bytes, 32 bits);
 *
 *@param str [IN]: the string to convert;
 *@param data [OUT]: the result is stored in this parm;
 *@return bool: if convert succeed, return true; else, return false;
 *@note there is a bug in qt library, so hex->int16->int32.
 */
bool Lms511Thread::Str2Int_32(QByteArray str, int* data)
{
    bool ok;
    unsigned int temp = str.toUInt(&ok, 16);
    memcpy(data, &temp, sizeof(int));
    return ok;
}
开发者ID:WuNL,项目名称:lab_workspace,代码行数:14,代码来源:Lms511Thread.cpp

示例4: runtime_error

// The reason we don't store stuff in a QString is because BitTorrent
// b-encoded strings may contain zeroes within the string, which makes
// a BString more of a buffer than a true string.
BString::BString (ByteStream &stream)
    : m_data()
{
    // A BString is \d+:.{n}, where n is whatever \d+ converted to.
    // So, read in the number part first.
    QByteArray numberData;

    while(*stream != ':') {
        numberData.append(*stream);
        ++stream;
    }

    ++stream; // Read past ':'

    bool validNumber = false;
    quint32 length = numberData.toUInt(&validNumber);

    if(!validNumber)
        throw std::runtime_error("Invalid number in string data");

    for(quint32 i = 0; i < length; ++i) {
        m_data.append(*stream);
        ++stream;
    }
}
开发者ID:KDE,项目名称:kdenetwork-strigi-analyzers,代码行数:28,代码来源:bstring.cpp

示例5: read

void Bdecoder::read(QByteArray *buf)
{
    int end = m_buf.indexOf(':', m_pos);
    if (end <= m_pos || end >= m_len) {
        setError("buffer overrun");
        return;
    }
    QByteArray s = m_buf.mid(m_pos, end - m_pos);
    m_pos = end + 1;

    if (!validateInt(s))
        return;
    bool ok;
    int strlen = s.toUInt(&ok, 10);
    if (!ok) {
        setError("Invalid string length (%s)", s.constData());
        return;
    }

    if (strlen + m_pos > m_len) {
        setError("buffer overrun");
        return;
    }
    if (buf)
        *buf = m_buf.mid(m_pos, strlen);
    m_pos += strlen;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:27,代码来源:bencode.cpp

示例6: transcode

static QString transcode(const QString &str, bool utf8)
{
    // Removed a and \a from here because it is not handled correctly by the linguist in our case
    static const char tab[] = "bfnrtv"; // removed a
    static const char backTab[] = "\b\f\n\r\t\v"; // removed \a
    const QString in = (!utf8 || yySourceIsUnicode)
        ? str : QString::fromUtf8(yySourceCodec->fromUnicode(str).data());
    QString out;

    out.reserve(in.length());
    for (int i = 0; i < in.length();) {
        ushort c = in[i++].unicode();
        if (c == '\\') {
            if (i >= in.length())
                break;
            c = in[i++].unicode();

            if (c == '\n')
                continue;

            if (c == 'x') {
                QByteArray hex;
                while (i < in.length() && isxdigit((c = in[i].unicode()))) {
                    hex += c;
                    i++;
                }
                out += hex.toUInt(0, 16);
            } else if (c >= '0' && c < '8') {
                QByteArray oct;
                int n = 0;
                oct += c;
                while (n < 2 && i < in.length() && (c = in[i].unicode()) >= '0' && c < '8') {
                    i++;
                    n++;
                    oct += c;
                }
                out += oct.toUInt(0, 8);
            } else {
                const char *p = strchr(tab, c);
                out += QString("\\") + QChar(QLatin1Char(!p ? c : backTab[p - tab]));
            }
        } else {
            out += c;
        }
    }
    return out;
}
开发者ID:CSV007,项目名称:siliconnexion,代码行数:47,代码来源:tpl.cpp

示例7: checkPuppetVersion

bool NodeInstanceServerProxy::checkPuppetVersion(const QString &qmlPuppetPath)
{
    QProcess qmlPuppetVersionProcess;
    qmlPuppetVersionProcess.start(qmlPuppetPath, QStringList() << "--version");
    qmlPuppetVersionProcess.waitForReadyRead(6000);

    QByteArray versionString = qmlPuppetVersionProcess.readAll();

    bool canConvert;
    unsigned int versionNumber = versionString.toUInt(&canConvert);

    return canConvert && versionNumber == 2;
}
开发者ID:darksylinc,项目名称:qt-creator,代码行数:13,代码来源:nodeinstanceserverproxy.cpp

示例8: QTcpSocket

GpsdMasterDevice::GpsdMasterDevice()
        : _socket( new QTcpSocket(this))
        , _hostname("localhost")
        , _port(2947)
        , _gpsdStarted(false)
{
  connect(_socket, SIGNAL( readyRead()), this, SLOT( readFromSocketAndCopy()));
  QByteArray hostname = qgetenv("GPSD_HOST");
  if( !hostname.isEmpty())
      _hostname = hostname;
  QByteArray port = qgetenv("GPSD_PORT");
  if( !port.isEmpty())
  {
    bool ok = false;
    uint tmp = port.toUInt(&ok);
    if(ok)
        _port = tmp;
  }
}
开发者ID:gohoho,项目名称:qtposition_gpsd,代码行数:19,代码来源:gpsdmasterdevice.cpp

示例9: rtcNow

QDateTime Qtopia::rtcNow()
{
    QByteArray secsStr = readFile("/sys/class/rtc/rtc0/since_epoch").trimmed();
    uint secs = secsStr.toUInt();
    return QDateTime::fromTime_t(secs);
}
开发者ID:Artox,项目名称:qtmoko,代码行数:6,代码来源:neocontrol.cpp

示例10: fetchNumber

bool Lexer::fetchNumber( double &d)
{
    char ch;
    d_source.peek( &ch, 1 );
    QByteArray number;

    enum State { Vorkomma, Nachkomma, Exponent2, Exponent1 };
    State state = Vorkomma;
    // Erstes Zeichen
    if( ch == '.' )
    {
        state = Nachkomma;
    }else if( !::isdigit( ch ) )
    {
        d_source.rewind();
        return false;
    }

    char ch2;
    d_source.peek( &ch2, 1 );
    if( state == Nachkomma && !::isdigit(ch2) )
    {
        d_source.rewind();
        return false; // wir haben einen Punkt gefunden, der aber nicht von einer Zahl gefolgt wird
    }

    bool ok;
    if( ch2 == 'x' )
    {
        if( ch != '0')
            return error("invalid number format");
        // Parse Hex
        while( true )
        {
            d_source.peek( &ch2, 1 );
            if( ::isdigit( ch2 ) || _isHexChar( ch2 ) )
                number += ch2;
            else
            {
                // Zahl ist fertig
                d = number.toUInt( &ok, 16 );
                if( !ok )
                    return error("invalid hex format");
                else
                {
                    d_source.eat( number.size() + 2 );
                    return true;
                }
            }
        }
    }else
    {
        // Parse Decimal
        number += ch;
        int anzNachkomma = 0;
        while( true )
        {
            switch( state )
            {
            case Vorkomma:
                if( ch2 == '.' )
                {
                    state = Nachkomma;
                }else if( ::isdigit( ch2 ) )
                    ;
                else if( ch2 == 'e' || ch2 == 'E' )
                {
                    state = Exponent1;
                    ch2 = 'e';
                }else
                {
                    d = number.toUInt( &ok );
                    if( !ok )
                        return error("invalid integer");
                    else
                    {
                        d_source.eat( number.size() );
                        return true;
                    }
                }
                number += ch2;
                break;
            case Nachkomma:
                if( ::isdigit( ch2 ) )
                    ;
                else if( ch2 == 'e' || ch2 == 'E' )
                {
                    if( anzNachkomma == 0 )
                        return error("invalid number format");
                    state = Exponent1;
                    ch2 = 'e';
                }else
                {
                    // Zahl ist fertig
                    if( anzNachkomma == 0 )
                        return error("invalid number format");
                    d = number.toDouble( &ok );
                    if( !ok )
                        return error("invalid decimal format");
                    else
//.........这里部分代码省略.........
开发者ID:rochus-keller,项目名称:NAF,代码行数:101,代码来源:ExpressionParser.cpp

示例11:

/**@brief convert QString to unsigned int (4 bytes, 32 bits);
 *
 *@param str [IN]: the string to convert;;
 *@param data [OUT]: the result is stored in this parm;
 *@return bool, if convert succeed, return true; else, return false;
 *@note
 */
bool Lms511Thread::Str2Uint_32(QByteArray str, unsigned int * data)
{
    bool ok;
    *data = str.toUInt(&ok, 16);
    return ok;
}
开发者ID:WuNL,项目名称:lab_workspace,代码行数:13,代码来源:Lms511Thread.cpp

示例12: updateFromPreferences

void EngineShoutcast::updateFromPreferences() {
    qDebug() << "EngineShoutcast: updating from preferences";

    m_pUpdateShoutcastFromPrefs->slotSet(0.0f);

    m_format_is_mp3 = false;
    m_format_is_ov = false;
    m_protocol_is_icecast1 = false;
    m_protocol_is_icecast2 = false;
    m_protocol_is_shoutcast = false;
    m_ogg_dynamic_update = false;

    // Convert a bunch of QStrings to QByteArrays so we can get regular C char*
    // strings to pass to libshout.

    QString codec = m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY, "metadata_charset"));
    QByteArray baCodec = codec.toLatin1();
    m_pTextCodec = QTextCodec::codecForName(baCodec);
    if (!m_pTextCodec) {
        qDebug() << "Couldn't find shoutcast metadata codec for codec:" << codec
                 << " defaulting to ISO-8859-1.";
    }

    // Indicates our metadata is in the provided charset.
    shout_metadata_add(m_pShoutMetaData, "charset",  baCodec.constData());

    // Host, server type, port, mountpoint, login, password should be latin1.
    QByteArray baHost = m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "host")).toLatin1();
    QByteArray baServerType = m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "servertype")).toLatin1();
    QByteArray baPort = m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "port")).toLatin1();
    QByteArray baMountPoint = m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "mountpoint")).toLatin1();
    QByteArray baLogin = m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "login")).toLatin1();
    QByteArray baPassword = m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "password")).toLatin1();
    QByteArray baFormat = m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "format")).toLatin1();
    QByteArray baBitrate = m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "bitrate")).toLatin1();

    // Encode metadata like stream name, website, desc, genre, title/author with
    // the chosen TextCodec.
    QByteArray baStreamName = encodeString(m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "stream_name")));
    QByteArray baStreamWebsite = encodeString(m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "stream_website")));
    QByteArray baStreamDesc = encodeString(m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "stream_desc")));
    QByteArray baStreamGenre = encodeString(m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "stream_genre")));
    QByteArray baStreamPublic = encodeString(m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "stream_public")));

    // Dynamic Ogg metadata update
    m_ogg_dynamic_update = (bool)m_pConfig->getValueString(
	        ConfigKey(SHOUTCAST_PREF_KEY,"ogg_dynamicupdate")).toInt();

    m_custom_metadata = (bool)m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "enable_metadata")).toInt();
    m_customTitle = m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "custom_title"));
    m_customArtist = m_pConfig->getValueString(
            ConfigKey(SHOUTCAST_PREF_KEY, "custom_artist"));

    int format;
    int protocol;

    if (shout_set_host(m_pShout, baHost.constData()) != SHOUTERR_SUCCESS) {
        errorDialog(tr("Error setting hostname!"), shout_get_error(m_pShout));
        return;
    }

    // WTF? Why SHOUT_PROTOCOL_HTTP and not.. the chosen protocol?
    if (shout_set_protocol(m_pShout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
        errorDialog(tr("Error setting protocol!"), shout_get_error(m_pShout));
        return;
    }

    if (shout_set_port(m_pShout, baPort.toUInt()) != SHOUTERR_SUCCESS) {
        errorDialog(tr("Error setting port!"), shout_get_error(m_pShout));
        return;
    }

    if (shout_set_password(m_pShout, baPassword.constData()) != SHOUTERR_SUCCESS) {
        errorDialog(tr("Error setting password!"), shout_get_error(m_pShout));
        return;
    }

    if (shout_set_mount(m_pShout, baMountPoint.constData()) != SHOUTERR_SUCCESS) {
        errorDialog(tr("Error setting mount!"), shout_get_error(m_pShout));
        return;
    }


    if (shout_set_user(m_pShout, baLogin.constData()) != SHOUTERR_SUCCESS) {
        errorDialog(tr("Error setting username!"), shout_get_error(m_pShout));
//.........这里部分代码省略.........
开发者ID:troyane,项目名称:mixxx,代码行数:101,代码来源:engineshoutcast.cpp

示例13: QVariant

bool
Field::setDefaultValue(const QByteArray& def)
{
    if (def.isNull()) {
        m_defaultValue = QVariant();
        return true;
    }

    bool ok;
    switch (type()) {
    case Byte: {
        unsigned int v = def.toUInt(&ok);
        if (!ok || v > 255)
            m_defaultValue = QVariant();
        else
            m_defaultValue = QVariant(v);
        break;
    }
    case ShortInteger: {
        int v = def.toInt(&ok);
        if (!ok || (!(m_options & Unsigned) && (v < -32768 || v > 32767)) || ((m_options & Unsigned) && (v < 0 || v > 65535)))
            m_defaultValue = QVariant();
        else
            m_defaultValue = QVariant(v);
        break;
    }
    case Integer: {//4 bytes
        long v = def.toLong(&ok);
//js: FIXME   if (!ok || (!(m_options & Unsigned) && (-v > 0x080000000 || v > (0x080000000-1))) || ((m_options & Unsigned) && (v < 0 || v > 0x100000000)))
        if (!ok || (!(m_options & Unsigned) && (-v > (int)0x07FFFFFFF || v > (int)(0x080000000 - 1))))
            m_defaultValue = QVariant();
        else
            m_defaultValue = QVariant((qint64)v);
        break;
    }
    case BigInteger: {//8 bytes
//! @todo BigInteger support
        /*
              qint64 long v = def.toLongLong(&ok);
        //TODO: 2-part decoding
              if (!ok || (!(m_options & Unsigned) && (-v > 0x080000000 || v > (0x080000000-1))))
                m_defaultValue = QVariant();
              else
                if (m_options & Unsigned)
                  m_defaultValue=QVariant((quint64) v);
                else
                  m_defaultValue = QVariant((qint64)v);*/
        break;
    }
    case Boolean: {
        unsigned short v = def.toUShort(&ok);
        if (!ok || v > 1)
            m_defaultValue = QVariant();
        else
            m_defaultValue = QVariant((bool)v);
        break;
    }
    case Date: {//YYYY-MM-DD
        QDate date = QDate::fromString(def, Qt::ISODate);
        if (!date.isValid())
            m_defaultValue = QVariant();
        else
            m_defaultValue = QVariant(date);
        break;
    }
    case DateTime: {//YYYY-MM-DDTHH:MM:SS
        QDateTime dt = QDateTime::fromString(def, Qt::ISODate);
        if (!dt.isValid())
            m_defaultValue = QVariant();
        else
            m_defaultValue = QVariant(dt);
        break;
    }
    case Time: {//HH:MM:SS
        QTime time = QTime::fromString(def, Qt::ISODate);
        if (!time.isValid())
            m_defaultValue = QVariant();
        else
            m_defaultValue = QVariant(time);
        break;
    }
    case Float: {
        float v = def.toFloat(&ok);
        if (!ok || ((m_options & Unsigned) && (v < 0.0)))
            m_defaultValue = QVariant();
        else
            m_defaultValue = QVariant(v);
        break;
    }
    case Double: {
        double v = def.toDouble(&ok);
        if (!ok || ((m_options & Unsigned) && (v < 0.0)))
            m_defaultValue = QVariant();
        else
            m_defaultValue = QVariant(v);
        break;
    }
    case Text: {
        if (def.isNull() || (uint(def.length()) > maxLength()))
            m_defaultValue = QVariant();
//.........这里部分代码省略.........
开发者ID:crayonink,项目名称:calligra-2,代码行数:101,代码来源:field.cpp


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