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


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

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


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

示例1: attributeToInt

int MStyleSheetAttribute::attributeToInt(const QByteArray &attribute, bool *conversionOk)
{
    QByteArray value = attribute.trimmed();

    if (attribute.endsWith(units[PIXELS_UNIT])) {
        // strip "px" from the end
        value.truncate(value.length() - 2);
        return value.toInt(conversionOk);
    }

    if (attribute.endsWith(units[MM_UNIT])) {
        // strip "mm" from the end
        value.truncate(value.length() - 2);

        return MDeviceProfile::instance()->mmToPixels(value.toFloat(conversionOk));
    }

    if (attribute.endsWith(units[PT_UNIT])) {
        // strip "pt" from the end
        value.truncate(value.length() - 2);

        return MDeviceProfile::instance()->ptToPixels(value.toFloat(conversionOk));
    }

    return value.toInt(conversionOk);
}
开发者ID:dudochkin-victor,项目名称:libgogootouch,代码行数:26,代码来源:mstylesheetattribute.cpp

示例2: readSocket

void PingPong::readSocket()
{
    if (!socket)
        return;
    const char sep = ' ';
    QByteArray line;
    while (socket->canReadLine()) {
        line = socket->readLine();
        //qDebug() << QString::fromUtf8(line.constData(), line.length());
        if (line.contains("result")) {
            QList<QByteArray> result = line.split(sep);
            if (result.size() > 2) {
                QByteArray leftSide = result.at(1);
                QByteArray rightSide = result.at(2);
                m_resultLeft = leftSide.toInt();
                m_resultRight = rightSide.toInt();
                Q_EMIT resultChanged();
                checkResult();
            }
        }
    }
    if ((m_proportionX == 0 || m_proportionY == 0)) {
        QList<QByteArray> boardSize = line.split(sep);
        if (boardSize.size() > 1) {
            QByteArray boardWidth = boardSize.at(0);
            QByteArray boardHeight = boardSize.at(1);
            m_proportionX = m_boardWidth/boardWidth.toFloat();
            m_proportionY = m_boardHeight/boardHeight.toFloat();
            setMessage("Screen adjusted. Get ready!");
            QTimer::singleShot(3000, this, SLOT(startGame()));
        }
    }
    else if (m_role == 1) {
        QList<QByteArray> boardSize = line.split(sep);
        if (boardSize.size() > 1) {
            QByteArray rightBlockY = boardSize.at(0);
            m_rightBlockY = m_proportionY * rightBlockY.toFloat();
            Q_EMIT rightBlockChanged();
        }
    }
    else if (m_role == 2) {
        QList<QByteArray> boardSize = line.split(sep);
        if (boardSize.size() > 2) {
            QByteArray ballX = boardSize.at(0);
            QByteArray ballY = boardSize.at(1);
            QByteArray leftBlockY = boardSize.at(2);
            m_ballX = m_proportionX * ballX.toFloat();
            m_ballY = m_proportionY * ballY.toFloat();
            m_leftBlockY = m_proportionY * leftBlockY.toFloat();
            Q_EMIT leftBlockChanged();
            Q_EMIT ballChanged();
        }
    }
}
开发者ID:lollinus,项目名称:qt-5.3-examples,代码行数:54,代码来源:pingpong.cpp

示例3: readConfiguredLoad

int MonarkConnection::readConfiguredLoad()
{
    m_serial->write("B\r");
    if (!m_serial->waitForBytesWritten(500))
    {
        // failure to write to device, bail out
        this->exit(-1);
    }
    QByteArray data = readAnswer(500);
    data.remove(0,1);
    qDebug() << "Current configure load: " << data.toInt();
    return data.toInt();
}
开发者ID:27sparks,项目名称:GoldenCheetah,代码行数:13,代码来源:MonarkConnection.cpp

示例4: qWarning

QT_BEGIN_NAMESPACE

QEglFSScreen::QEglFSScreen(EGLDisplay dpy)
    : m_dpy(dpy),
      m_surface(EGL_NO_SURFACE),
      m_cursor(0),
      m_rootContext(0)
{
#ifdef QEGL_EXTRA_DEBUG
    qWarning("QEglScreen %p\n", this);
#endif

    QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR");
    bool hideCursor = false;
    if (hideCursorVal.isEmpty()) {
#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
        QScopedPointer<QDeviceDiscovery> dis(QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse));
        hideCursor = dis->scanConnectedDevices().isEmpty();
#endif
    } else {
        hideCursor = hideCursorVal.toInt() != 0;
    }
    if (!hideCursor)
        m_cursor = QEglFSHooks::hooks()->createCursor(this);
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:25,代码来源:qeglfsscreen.cpp

示例5: getHdcpStatus

bool Matrix::getHdcpStatus(QByteArray input)
{
    QByteArray resp;
    QByteArray esc = "\x1B";
    resp = dxpClient->sendQuery(esc + "E" + input + "HDCP\r").trimmed();
    return resp.toInt();
}
开发者ID:martialgallorini,项目名称:auditControl,代码行数:7,代码来源:matrix.cpp

示例6: xResource

bool QXcbScreen::xResource(const QByteArray &identifier,
                           const QByteArray &expectedIdentifier,
                           int *value)
{
    Q_ASSERT(value != 0);
    if (identifier.startsWith(expectedIdentifier)) {
        QByteArray stringValue = identifier.mid(expectedIdentifier.size());

        bool ok;
        *value = stringValue.toInt(&ok);
        if (!ok) {
            if (stringValue == "hintfull")
                *value = QFontEngine::HintFull;
            else if (stringValue == "hintnone")
                *value = QFontEngine::HintNone;
            else if (stringValue == "hintmedium")
                *value = QFontEngine::HintMedium;
            else if (stringValue == "hintslight")
                *value = QFontEngine::HintLight;

            return *value != 0;
        }

        return true;
    }

    return false;
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:28,代码来源:qxcbscreen.cpp

示例7: if

CrossFlip::CrossFlip(QByteArray fileData){
    fileData = fileData.mid(fileData.indexOf("var boardinit"));
    fileData = fileData.mid(0, fileData.indexOf("</script>"));

    QByteArray board;
    board = fileData.mid(fileData.indexOf("\"")+1);
    board = board.mid(0, board.indexOf("\""));
    std::vector<bool> bufferBlocked, bufferStartValue;
    for(int i=0; i< board.size(); ++i){
        if(board[i] == ','){
            Blocked.push_back(bufferBlocked);
            startValue.push_back(bufferStartValue);
            bufferBlocked.clear();
            bufferStartValue.clear();
            continue;
        }
        if(board[i] == '0'){
            bufferBlocked.push_back(false);
            bufferStartValue.push_back(false);
        }else if(board[i] == '1'){
            bufferBlocked.push_back(false);
            bufferStartValue.push_back(true);
        }else if(board[i] == '2'){
            bufferBlocked.push_back(true);
            bufferStartValue.push_back(false);
        }
    }
    Blocked.push_back(bufferBlocked);
    startValue.push_back(bufferStartValue);
    QByteArray lev = fileData;
    lev = lev.mid(lev.indexOf("level"));
    lev = lev.mid(lev.indexOf("=")+2);
    lev = lev.mid(0, lev.indexOf(";"));
    level = lev.toInt();
}
开发者ID:Fettpet,项目名称:Hackerorg,代码行数:35,代码来源:cross.cpp

示例8: readMessage

void QTcpClient::readMessage()
{
    qDebug()<<"////////////////";
    qint64 numc = 0;
    qint64 numb = tcpsocket->bytesAvailable();
    qDebug()<<numb<<"  numb";
    while(numc < numb)
    {
        int type = 0;
        int length = 0;
        QByteArray databy;
        databy = tcpsocket->read(1);
        numc++;
        type = databy.toInt();
        if(type != m_type)
        {
            databy = tcpsocket->readAll();
            databy.clear();
            continue;
        }
        databy.clear();
        databy = tcpsocket->read(4);
        numc = numc + 4;
        length = Char2Dec(databy.data());
        if(length == 0)
        {
            continue;
        }
        databy.clear();
        databy = tcpsocket->read(length);
        numc = numc +length;
        qDebug()<<m_time.currentDateTime().toString("hh:mm:ss.zzz")<<" Lib";
        (*g_callRead)(databy);
    }
}
开发者ID:eilin1208,项目名称:QT_Test,代码行数:35,代码来源:qtcpclient.cpp

示例9: readOther

QVariant StelJsonParserInstance::readOther()
{
	QByteArray str;
	char c;
	while (getChar(&c))
	{
		if (c==' ' || c==',' || c=='\n' || c=='\r' || c==']' || c=='\t' || c=='}')
		{
			ungetChar(c);
			break;
		}
		str+=c;
	}
	bool ok;
	const int i = str.toInt(&ok);
	if (ok)
		return i;
	const double d = str.toDouble(&ok);
	if (ok)
		return d;
	if (str=="true")
		return QVariant(true);
	if (str=="false")
		return QVariant(false);
	if (str=="null")
		return QVariant();
	QDateTime dt = QDateTime::fromString(str, Qt::ISODate);
	if (dt.isValid())
		return QVariant(dt);

	throw std::runtime_error(qPrintable(QString("Invalid JSON value: \"")+str+"\""));
}
开发者ID:EvilTosha,项目名称:Stellarium-GSoC12,代码行数:32,代码来源:StelJsonParser.cpp

示例10: decodePropertyValue

QString DevicePrivate::decodePropertyValue(const QByteArray &encoded) const
{
    QByteArray decoded;
    const int len = encoded.length();

    for (int i = 0; i < len; i++) {
        quint8 ch = encoded.at(i);

        if (ch == '\\') {
            if (i + 1 < len && encoded.at(i + 1) == '\\') {
                decoded.append('\\');
                i++;
                continue;
            } else if (i + 3 < len && encoded.at(i + 1) == 'x') {
                QByteArray hex = encoded.mid(i + 2, 2);
                bool ok;
                int code = hex.toInt(&ok, 16);
                if (ok)
                    decoded.append(char(code));
                i += 3;
                continue;
            }
        } else {
            decoded.append(ch);
        }
    }
    return QString::fromUtf8(decoded);
}
开发者ID:gustavosbarreto,项目名称:libqsolid,代码行数:28,代码来源:udevqtdevice.cpp

示例11: interval

unsigned int GyroscopeAdaptor::interval() const
{
    if (mode() == SysfsAdaptor::IntervalMode)
        return SysfsAdaptor::interval();
    QByteArray byteArray = readFromFile(dataRatePath_);
    return byteArray.size() > 0 ? byteArray.toInt() : 0;
}
开发者ID:filippz,项目名称:sensorfw,代码行数:7,代码来源:gyroscopeadaptor.cpp

示例12: memcpy

/**@brief convert QString to float (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 hex->decimal->float
 */
bool Lms511Thread::Str2Real(QByteArray str, float* data)
{
    bool ok = false;
    int n = str.toInt(&ok, 16);
    memcpy(data, &n, sizeof(float));
    return ok;
}
开发者ID:WuNL,项目名称:lab_workspace,代码行数:14,代码来源:Lms511Thread.cpp

示例13: parseStatus

bool QHttpNetworkReplyPrivate::parseStatus(const QByteArray &status)
{
    // from RFC 2616:
    //        Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
    //        HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT
    // that makes: 'HTTP/n.n xxx Message'
    // byte count:  0123456789012

    static const int minLength = 11;
    static const int dotPos = 6;
    static const int spacePos = 8;
    static const char httpMagic[] = "HTTP/";

    if (status.length() < minLength
        || !status.startsWith(httpMagic)
        || status.at(dotPos) != '.'
        || status.at(spacePos) != ' ') {
        // I don't know how to parse this status line
        return false;
    }

    // optimize for the valid case: defer checking until the end
    majorVersion = status.at(dotPos - 1) - '0';
    minorVersion = status.at(dotPos + 1) - '0';

    int i = spacePos;
    int j = status.indexOf(' ', i + 1); // j == -1 || at(j) == ' ' so j+1 == 0 && j+1 <= length()
    const QByteArray code = status.mid(i + 1, j - i - 1);

    bool ok;
    statusCode = code.toInt(&ok);
    reasonPhrase = QString::fromLatin1(status.constData() + j + 1);

    return ok && uint(majorVersion) <= 9 && uint(minorVersion) <= 9;
}
开发者ID:fluxer,项目名称:katie,代码行数:35,代码来源:qhttpnetworkreply.cpp

示例14: readMyCom

//读取数据
void MainWindow::readMyCom()
{
    QByteArray temp = myCom->readAll();

    if(!temp.isEmpty()){

        if(write2fileName.isEmpty()){
            ui->textBrowser->setTextColor(Qt::lightGray);
            ui->textBrowser->append(tr("接收: "));
            ui->textBrowser->setTextColor(Qt::black);
            if(ui->ccradioButton->isChecked()){
                ui->textBrowser->append(temp);
            }else if(ui->chradioButton->isChecked()){
                ui->textBrowser->append(tr("")+temp.toHex());
            }else{
                ui->textBrowser->append(tr("")+temp.toInt());
            }

        }else{
            QFile file(write2fileName);
            //如果打开失败则给出提示并退出函数
            if(!file.open(QFile::Append | QIODevice::Text)){
                QMessageBox::warning(this, tr("写入文件"), tr("打开文件 %1 失败, 无法写入\n%2").arg(write2fileName).arg(file.errorString()), QMessageBox::Ok);
                return;
            }
            QTextStream out(&file);
            out<<temp<<endl;
            file.close();
            ui->textBrowser->append(tr("接收:数据已经写入文件 %1").arg(write2fileName));
        }

        ui->recvbyteslcdNumber->display(ui->recvbyteslcdNumber->value() + temp.size());
        ui->statusBar->showMessage(tr("成功读取%1字节数据").arg(temp.size()));
    }
}
开发者ID:hitxqh,项目名称:helloworld,代码行数:36,代码来源:mainwindow.cpp

示例15: initialize

static void QWebOSGLContext::initialize(EGLNativeDisplayType display)
{
    EGLint major, minor;

   if (!eglBindAPI(EGL_OPENGL_ES_API)) {
        qWarning("Could not bind GL_ES API\n");
        qFatal("EGL error");
    }

    s_eglDisplay = eglGetDisplay(display);
    if (s_eglDisplay == EGL_NO_DISPLAY)
        qDebug() << "Could not open egl display\n";

    if (!eglInitialize(s_eglDisplay, &major, &minor))
        qDebug() << "Could not initialize egl display";

    int swapInterval = 1;
    QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL");
    if (!swapIntervalString.isEmpty()) {
        bool ok;
        swapInterval = swapIntervalString.toInt(&ok);
        if (!ok)
            swapInterval = 1;
    }

    eglSwapInterval(s_eglDisplay, swapInterval);
}
开发者ID:Tofee,项目名称:qt-webos-plugin,代码行数:27,代码来源:qwebosglcontext.cpp


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