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


C++ QString::begin方法代码示例

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


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

示例1: consumeNumber

AnimExpression::Token AnimExpression::consumeNumber(const QString& str, QString::const_iterator& iter) const {
    assert(iter != str.end());
    assert(iter->isDigit());
    auto begin = iter;
    while (iter->isDigit() && iter != str.end()) {
        ++iter;
    }

    // parse whole integer part
    int pos = (int)(begin - str.begin());
    int len = (int)(iter - begin);
    QString sub = QStringRef(const_cast<const QString*>(&str), pos, len).toString();
    int whole = sub.toInt();

    // parse optional fractional part
    if (iter->unicode() == '.') {
        iter++;
        auto begin = iter;
        while (iter->isDigit() && iter != str.end()) {
            ++iter;
        }

        int pos = (int)(begin - str.begin());
        int len = (int)(iter - begin);
        QString sub = QStringRef(const_cast<const QString*>(&str), pos, len).toString();
        int fraction = sub.toInt();

        return Token(computeFloat(whole, fraction));

    } else {
        return Token(whole);
    }
}
开发者ID:AlphaStaxLLC,项目名称:hifi,代码行数:33,代码来源:AnimExpression.cpp

示例2: getModelData

ModelData* ModelComponent::getModelData(){
    ModelData *md = new ModelData();
    std::map<char,std::vector<QString>* > numbers;

    for(std::map<char, QLineEdit*>::iterator i = components.begin(); i != components.end(); i++){

        QString txt = i->second->text();
        int count = 0;

        std::vector<QString> *vecString = new std::vector<QString>();
        vecString->push_back("");
        numbers[i->first] = vecString;

        QString::iterator j = txt.begin();

        for(QString::iterator j = txt.begin(); j != txt.end(); j++){

            if(((*j) >= '0' && (*j) <= '9') || (*j) == ',' || (*j) == '.' || (*j)=='-'){ //ten warunek mozna poprawic(chodzi o wystapienie dwoch kropek albo minusow
                vecString->at(count).push_back( (*j));
            }else if((*j) == 32){
                    count++;
                    vecString->push_back("");
            }else{
                break;
                //TODO throw execption
            }
        }

        if(vecString->back() == "" ){
            vecString->pop_back();
        }
    }

    std::vector<QString>* A = numbers.at('A');
    std::vector<double> Adouble;

    for(std::vector<QString>::iterator i = A->begin(); i != A->end(); i++){
        Adouble.push_back((*i).toDouble());
    }
    md->setA(Adouble);

    std::vector<QString>* B = numbers.at('B');
    std::vector<double> Bdouble;
    for(std::vector<QString>::iterator i = B->begin(); i != B->end(); i++){
        Bdouble.push_back((*i).toDouble());
    }
    md->setB(Bdouble);

    std::vector<QString>* k = numbers.at('k');
    md->setK(k->at(0).toDouble());

    std::vector<QString>* t = numbers.at('t');
    md->setT(t->at(0).toDouble());

    std::vector<QString>* nr = numbers.at('nr');
    md->setNoiseRatio(nr->at(0).toDouble());
    return md;
}
开发者ID:jakubbialas,项目名称:PSS_lab,代码行数:58,代码来源:modelcomponent.cpp

示例3: searchInString

bool MainWindow::searchInString(const QString& where, const QString& what)
{
    auto it = std::search(
        where.begin(), where.end(),
        what.begin(), what.end(),
        [](QChar ch1, QChar ch2) { return ch1.toUpper() == ch2.toUpper(); }
    );

    return it == where.begin();
}
开发者ID:metthal,项目名称:ITU-Projekt,代码行数:10,代码来源:mainwindow.cpp

示例4: globMatch

    // TODO: directly unit test this
    bool globMatch(const QString &pattern, const QString &haystack) {
        QString::const_iterator patIt(pattern.begin());
        QString::const_iterator hayIt(haystack.begin());

        bool escaping(false);

        while (hayIt != haystack.end() && (escaping || *patIt != '%')) {

            if (!escaping && *patIt == '\\') {
                escaping = true;
                ++patIt;
                continue;
            }

            if ((patIt->toLower() != hayIt->toLower()) && (escaping || *patIt != '_'))
                return false;

            escaping = false;
            ++hayIt;
            ++patIt;
         }

        QString::const_iterator tPatIt(pattern.end());
        QString::const_iterator tHayIt(haystack.end());

        while (patIt != pattern.end() && hayIt != haystack.end()) {

            if (!escaping && *patIt == '\\') {
                escaping = true;
                ++patIt;
            } else if (!escaping && *patIt == '%') {
                if (++patIt == pattern.end())
                    return true;

                tPatIt = patIt;
                tHayIt = hayIt + 1;
            } else if (patIt->toLower() == hayIt->toLower() || (!escaping && *patIt == '_')) {
                escaping = false;
                ++patIt;
                ++hayIt;
            } else {
                escaping = false;
                patIt = tPatIt;
                hayIt = tHayIt++;
            }
        }

        // eat trailing %
        while (patIt != pattern.end() && *patIt == '%') {
            ++patIt;
        }

        return hayIt == haystack.end() && patIt == pattern.end();
    }
开发者ID:RobinD42,项目名称:qt-mobility,代码行数:55,代码来源:messagingutil.cpp

示例5: Escape

QString ParameterizedCommand::Escape(const QString& rawText)
{

  QString buffer;

  for (QString::const_iterator i = rawText.begin();
      i != rawText.end(); ++i)
  {

    QString::value_type c = *i;
    if (c == CommandManager::PARAMETER_START_CHAR ||
        c == CommandManager::PARAMETER_END_CHAR ||
        c == CommandManager::ID_VALUE_CHAR ||
        c == CommandManager::PARAMETER_SEPARATOR_CHAR ||
        c == CommandManager::ESCAPE_CHAR)
    {
      buffer += CommandManager::ESCAPE_CHAR;
    }

    buffer += c;
  }

  if (buffer.isEmpty())
  {
    return rawText;
  }
  return buffer;
}
开发者ID:ghisvail,项目名称:MITK,代码行数:28,代码来源:berryParameterizedCommand.cpp

示例6: maxSubstring

QString Util::maxSubstring(const QString &s1, const QString &s2)
{
    std::tuple<Matrix,ArrowTable> len= maxSubstringLength(s1,s2);
    QString result = maxSubstringRecur(std::get<1>(len),s1,s1.length(),s2.length(),QString(""));
    std::reverse(result.begin(),result.end());
    return result;
}
开发者ID:alesapin,项目名称:HearhRecognizer,代码行数:7,代码来源:util.cpp

示例7: preferredCharsetFor

/*!
    Returns the first charset from the preferred list that is capable of encoding
    the content of \a text.

    \since 1.0
    \sa preferredCharsets(), setBody()
*/
QByteArray QMessage::preferredCharsetFor(const QString &text)
{
    QList<QTextCodec*> codecs;
    foreach (const QByteArray &name, charsets) {
        if (QTextCodec* codec = QTextCodec::codecForName(name)) {
            codecs.append(codec);
        } else {
            qWarning() << "No codec is available for:" << name;
        }
    }

    if (!codecs.isEmpty()) {
        // See if any of these codecs can encode the data
        QString::const_iterator sit = text.begin(), end = text.end();
        for ( ; sit != end; ++sit) {
            QList<QTextCodec*>::iterator cit = codecs.begin();
            if (!(*cit)->canEncode(*sit)) {
                // This codec is not acceptable
                cit = codecs.erase(cit);
                if (codecs.isEmpty()) {
                    break;
                }
            } else {
                ++cit;
            }
        }

        if (!codecs.isEmpty()) {
            // Return the first remaining codec
            return codecs.first()->name();
        }
    }

    return QByteArray();
}
开发者ID:RobinD42,项目名称:qt-mobility,代码行数:42,代码来源:qmessage.cpp

示例8: sort

void PlayListWidget::sort(const QStringList &list)
{
    static QString first;
    static QString second;
    static QStringList tmp;
    static auto comp = [](QString::value_type it) {return it.isDigit();};
    for_each(list.begin(), list.end(), [&](const QStringList::value_type & item) {
        second.clear();
        tmp = item.split("$$");
        first = tmp[0];
        auto digit_begin = find_if(first.begin(), first.end(), comp);
        auto digit_end = find_if_not(digit_begin, first.end(), comp);
        std::copy(digit_begin, digit_end, std::back_inserter(second));
        play_list.append(list_map {std::make_tuple<QString, QString, QString>(
                                       QString("%1").arg(second.toInt(), 10, 10, QChar('0')),
                                       std::move(first),
                                       std::move(tmp[1]))
                                  });
    });
    std::sort(play_list.begin(), play_list.end(),
              [](list_map::const_iterator::value_type lvalue,
    list_map::const_iterator::value_type rvalue) {
        return std::get<0>(lvalue) < std::get<0>(rvalue);
    });
}
开发者ID:karllen,项目名称:kuplayer,代码行数:25,代码来源:play_list_widget.cpp

示例9: CheckFileName

bool ViewNewMapDialog::CheckFileName(QString fileNameWithoutExtension)
{
    if(fileNameWithoutExtension.isEmpty())
    {
        QMessageBox::warning(this, tr("Warning ..."), tr("No file name was set."));
        return false;
    }
    if(fileNameWithoutExtension.size() > GLOBAL_CONSTS::MaximumMapFileNameSizeWithoutExtension)
    {
        QMessageBox::warning(this,
                             tr("Warning ..."),
                             tr("Your file name is too long. Maximum length is %1, yours length is %2.")\
                                .arg( QString::number( GLOBAL_CONSTS::MaximumMapFileNameSizeWithoutExtension ),\
                                      QString::number( fileNameWithoutExtension.size() ) ));
        return false;
    }
    if(fileNameWithoutExtension.at(0) == '-')
    {
        QMessageBox::warning(this, tr("Warning ..."), tr("File name first charachter can not be '-'."));
        return false;
    }
    for(QString::Iterator it = fileNameWithoutExtension.begin(); it != fileNameWithoutExtension.end(); ++it)
    {
        if(!(it->isLetterOrNumber()))
        {
            if(it->cell() != '.' && it->cell() != '_' && it->cell() != '-')
            {
                QMessageBox::warning(this, tr("Warning ..."), tr("File name can not contain '%1' charachter.").arg(*it));
                return false;
            }
        }
    }
    return true;
}
开发者ID:AidanPryde,项目名称:SWR_MapEditor,代码行数:34,代码来源:viewnewmapdialog.cpp

示例10: while

static QString
escape_shell_windows(QString const &source) {
  if (!source.contains(QRegExp{"[\\w+,\\-./:[email protected]]"}))
    return source;

  auto copy = QString{'"'};

  for (auto it = source.begin(), end = source.end() ; ; ++it) {
    QString::size_type numBackslashes = 0;

    while ((it != end) && (*it == QChar{'\\'})) {
      ++it;
      ++numBackslashes;
    }

    if (it == end) {
      copy += QString{numBackslashes * 2, QChar{'\\'}};
      break;

    } else if (*it == QChar{'"'})
      copy += QString{numBackslashes * 2 + 1, QChar{'\\'}} + *it;

    else
      copy += QString{numBackslashes, QChar{'\\'}} + *it;
  }

  copy += QChar{'"'};

  copy.replace(QRegExp{"([()%!^\"<>&|])"}, Q("^\\1"));

  return copy;
}
开发者ID:RaceOfAce,项目名称:mkvtoolnix,代码行数:32,代码来源:util.cpp

示例11: translatedToVanity

QString QPhoneNumberString::translatedToVanity(const QString str) {
    QString vanityString;
    for  (QString::const_iterator i = str.begin(); i != str.end(); i++) {
        vanityString.append( translatedToVanity(*i) );
    }
    return vanityString;
}
开发者ID:Farom,项目名称:kfffeed,代码行数:7,代码来源:qphonenumberstring.cpp

示例12: checkSection

void KTextEditingPlugin::checkSection(QTextDocument *document, int startPosition, int endPosition)
{
    QTextBlock block = document->findBlock(startPosition);
    int pos = block.position();
    while (true) {
        if (!block.contains(startPosition - 1) && !block.contains(endPosition + 1)) // only parags that are completely in
            finishedParagraph(document, block.position());

        QString text = block.text();
        bool space = true;
        QString::Iterator iter = text.begin();
        while (pos < endPosition && iter != text.end()) {
            bool isSpace = iter->isSpace();
            if (pos >= startPosition && space && !isSpace) // for each word, call finishedWord
                finishedWord(document, pos);
            else if (!isSpace && pos == startPosition)
                finishedWord(document, startPosition);
            space = isSpace;
            pos++;
            iter++;
        }

        if (!(block.isValid() && block.position() + block.length() < endPosition))
            break;
        block = block.next();
    }
}
开发者ID:KDE,项目名称:koffice,代码行数:27,代码来源:KTextEditingPlugin.cpp

示例13: validateTopicName

    static void validateTopicName(const QString& topic)
    {
        if (topic.isEmpty())
        {
            throw std::invalid_argument("empty topic");
        }

        // Can't start or end with a '/' but anywhere else is okay
        // Can't have "//" as that implies empty token
        if (topic.startsWith("/") || topic.endsWith("/") ||
                topic.contains("//"))
        {
            throw std::invalid_argument(QString("invalid topic: %1").arg(topic).toStdString());
        }

        QString::const_iterator topicEnd = topic.end();
        QChar A('A'), Z('Z'), a('a'), z('z'), zero('0'), nine('9');
        QChar dash('-'), slash('/'), underscore('_');
        for (QString::const_iterator i = topic.begin(); i < topicEnd; ++i)
        {
            QChar c(*i);
            if ((A <= c) && (c <= Z)) continue;
            if ((a <= c) && (c <= z)) continue;
            if ((zero <= c) && (c <= nine)) continue;
            if ((c == underscore) || (c == dash) || (c == slash)) continue;
            throw std::invalid_argument(QString("invalid topic: %1").arg(topic).toStdString());
        }
    }
开发者ID:domibel,项目名称:CTK,代码行数:28,代码来源:ctkBusEvent.cpp

示例14: parseMessage

 void MainWindow::parseMessage(QString const& message)
 {
     std::vector<QString> stats;
     stats.push_back(QString());
     QString::const_iterator it = message.begin();
     QString::const_iterator itEnd = message.end();
     for (; it != itEnd; ++it)
         if (*it == ' ')
             stats.push_back(QString());
         else
             stats.back() += *it;
     if (stats.size() >= 6)
     {
         // uptime
         QDateTime t(QDate::currentDate());
         t = t.addMSecs(stats[0].toInt());
         this->uptimeLabel->setText("Uptime: " + t.toString("hh:mm:ss"));
         // upload
         this->_uploadGraph->addValue(static_cast<float>(stats[1].toInt()) / 1000.0f);
         // download
         this->_downloadGraph->addValue(static_cast<float>(stats[2].toInt()) / 1000.0f);
         // requests
         this->_requestsGraph->addValue(stats[3].toInt());
         // buffers
         this->_buffersGraph->addValue(stats[4].toInt());
         // memory
         this->_memoryGraph->addValue(static_cast<float>(stats[5].toInt()) / 1000.0f);
     }
 }
开发者ID:hotgloupi,项目名称:zhttpd,代码行数:29,代码来源:MainWindow.cpp

示例15: todosAscii

bool todosAscii(const QString& s)
{
    for (QString::const_iterator it = s.begin(); it != s.end(); ++it)
        if (it->unicode() > 127)
            return false;
    return true;
}
开发者ID:lagenar,项目名称:clprover,代码行数:7,代码来源:qclprover.cpp


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