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


C++ QRegExp::cap方法代码示例

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


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

示例1: dropEvent

void NewWakuSettingsWindow::dropEvent(QDropEvent *event)
{
  const QRegExp broadIDrg("^.+lv(\\d+).*$");
  if (broadIDrg.indexIn(event->mimeData()->text()) != -1) {
    mwin->getNewWakuAPI(0, broadIDrg.cap(1));
    event->acceptProposedAction();
  } else {
    event->dropAction();
  }

}
开发者ID:GitHub30,项目名称:Viqo,代码行数:11,代码来源:newwakusettingswindow.cpp

示例2: bbNum

int  Icc_parser::bbNum(std::string &in)
{
	QRegExp regexp;
	QString str(in.c_str());

	regexp.setPattern( icc_patt_bb);
	if ( regexp.indexIn( str) != -1)
		return regexp.cap( 2).toInt();
	else
		return -1;
}
开发者ID:MIPT-ILab,项目名称:MIPT-Vis,代码行数:11,代码来源:icc_parser.cpp

示例3: preprocessorLine

// Determine type of line and return enumeration, cut out
// expression for '@if/@elsif'.
PreprocessorSection PreprocessContext::preprocessorLine(const QString &in,
                                                        QString *ifExpression) const
{
    if (m_ifPattern.exactMatch(in)) {
        *ifExpression = m_ifPattern.cap(2).trimmed();
        return IfSection;
    }
    if (m_elsifPattern.exactMatch(in)) {
        *ifExpression = m_elsifPattern.cap(2).trimmed();
        return ElsifSection;
    }

    ifExpression->clear();

    if (m_elsePattern.exactMatch(in))
        return ElseSection;
    if (m_endifPattern.exactMatch(in))
        return EndifSection;
    return OtherSection;
}
开发者ID:qtproject,项目名称:qt-creator,代码行数:22,代码来源:templateengine.cpp

示例4: GotoPage

void PageSelector::GotoPage()
{
	static QRegExp rx("^([0-9])+.*");
	int p = rx.cap(1).toInt();
	if (p < 1)
		p=1;
	if (p > LastPG)
		p = LastPG;
	GotoPg(p-1);
	emit GotoPage(p);
}
开发者ID:ivro,项目名称:scribus,代码行数:11,代码来源:pageselector.cpp

示例5: isFnName

string  Icc_parser::isFnName(std::string &in)
{
	QRegExp regexp;
	QString str(in.c_str());

	regexp.setPattern( icc_patt_fnname);
	if ( regexp.indexIn( str, 0) != -1)
		return regexp.cap( 1).toAscii().constData();
	else
		return "";
}
开发者ID:MIPT-ILab,项目名称:MIPT-Vis,代码行数:11,代码来源:icc_parser.cpp

示例6: parseResource

QString VariableParser::parseResource()
{
  //z:6:\"stream\":3;
  QRegExp rx;
  rx.setPattern("z:\\d*:[^:]*:(\\d*);");

  if(rx.search(m_raw, m_index) == -1) return "";
  m_index += rx.matchedLength();

  return rx.cap(1);
}
开发者ID:thiago-silva,项目名称:protoeditor,代码行数:11,代码来源:variableparser.cpp

示例7: parseClassType

QString VariableParser::parseClassType()
{
  //O:6:"Classe":3:{s:6:...
  QRegExp rx;
  rx.setPattern("O:\\d*:\"([^\"]*)\":");

  if(rx.search(m_raw, m_index) == -1) return "";
  m_index += rx.matchedLength();

  return rx.cap(1);
}
开发者ID:thiago-silva,项目名称:protoeditor,代码行数:11,代码来源:variableparser.cpp

示例8: parseVersion

static int parseVersion(const QString &text)
{
    // The version in Artistic Style is printed like "Artistic Style Version 2.04"
    const QRegExp rx("([2-9]{1})\\.([0-9]{2})(\\.[1-9]{1})?$");
    if (rx.indexIn(text) != -1) {
        const int major = rx.cap(1).toInt() * 100;
        const int minor = rx.cap(2).toInt();
        return major + minor;
    }
    return 0;
}
开发者ID:C-sjia,项目名称:qt-creator,代码行数:11,代码来源:artisticstylesettings.cpp

示例9: GetURLsFromText

 QList<QUrl> GetURLsFromText(const QString &searchText)
 {
     QList<QUrl> retList;
     QRegExp searchRX = QRegExp("\\b(?:http|https)://(?:[a-z0-9]\\.)?(?:[\\-\\.a-z0-9]+)*[a-z0-9]{2,}(?::[0-9]{1,5})?(?:/\\S*(?:\\.\\S+))*/*", Qt::CaseInsensitive);
     int pos = 0;
     while ((pos = searchRX.indexIn(searchText, pos)) != -1) {
             retList.append(QUrl(searchRX.cap(0)));
             pos += searchRX.matchedLength();
     }
     return retList;
 }
开发者ID:dudochkin-victor,项目名称:marmazon,代码行数:11,代码来源:stringutils.cpp

示例10: validate

QValidator::State KoUnitDoubleSpinBox::validate(QString &input, int &pos) const
{
#ifdef DEBUG_VALIDATOR
    kDebug(30004) <<"KoUnitDoubleSpinBox::validate :" << input <<" at" << pos;
#else
    Q_UNUSED(pos);
#endif

    QRegExp regexp ("([ a-zA-Z]+)$"); // Letters or spaces at end
    const int res = input.indexOf( regexp );

    if ( res == -1 )
    {
        // Nothing like an unit? The user is probably editing the unit
#ifdef DEBUG_VALIDATOR
        kDebug(30004) <<"Intermediate (no unit)";
#endif
        return QValidator::Intermediate;
    }

    // ### TODO: are all the QString::trimmed really necessary?
    const QString number ( input.left( res ).trimmed() );
    const QString unitName ( regexp.cap( 1 ).trimmed().toLower() );

#ifdef DEBUG_VALIDATOR
    kDebug(30004) <<"Split:" << number <<":" << unitName <<":";
#endif

    const double value = valueFromText( number );
    double newVal = 0.0;
    if (!isnan(value)) {
        bool ok;
        const KoUnit unit = KoUnit::fromSymbol(unitName, &ok);
        if ( ok )
            newVal = unit.fromUserValue( value );
        else
        {
            // Probably the user is trying to edit the unit
#ifdef DEBUG_VALIDATOR
            kDebug(30004) <<"Intermediate (unknown unit)";
#endif
            return QValidator::Intermediate;
        }
    }
    else
    {
        kWarning(30004) << "Not a number: " << number;
        return QValidator::Invalid;
    }
    newVal = KoUnit::ptToUnit( newVal, d->unit );
    //input = textFromValue( newVal ); // don't overwrite for now; the effect is not exactly what I expect...

    return QValidator::Acceptable;
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:54,代码来源:KoUnitDoubleSpinBox.cpp

示例11: isTotalTime

 /*!
     判断指定字符串中是否含有文件名
     预期输入为: ID_LENGTH=239.00
     输出为:239
              true
   \param 【IN】QString &line_data mplaer 输出的一行信息
   \param 【OUT】int &total_tme 做为输出时间,以秒为单位.
  */
 bool IBMediaControlCData::isTotalTime(const QString & line_data,int &total_tme)
 {
     int index = -1;
     index = m_rx_total_length.indexIn(line_data);
     if(index>-1)
     {
         total_tme = (int)m_rx_total_length.cap(1).toDouble();
         return true;
     }
     return false;
 }
开发者ID:bgtwoigu,项目名称:code808,代码行数:19,代码来源:ibMediaControl.cpp

示例12: parseInt

QString VariableParser::parseInt()
{
  QRegExp rx;
  //rx.setPattern("i:(\\d*);"); //crash if the number is negative, ie. "i:-1". \\d doesn't reconize negatives
  rx.setPattern("i:([^;]*);");

  if(rx.search(m_raw, m_index) == -1) return "";
  m_index += rx.matchedLength();

  return rx.cap(1);
}
开发者ID:thiago-silva,项目名称:protoeditor,代码行数:11,代码来源:variableparser.cpp

示例13: highlightBlock

void SpellHighlighter::highlightBlock(const QString &AText)
{
	if (FEnabled)
	{
		// Match words (minimally) excluding digits within a word
		static const QRegExp expression("\\b[^\\s\\d]+\\b");

		int index = 0;
		while ((index = expression.indexIn(AText, index)) != -1)
		{
			int length = expression.matchedLength();
			if (!isUserNickName(expression.cap()))
			{
				if (!SpellBackend::instance()->isCorrect(expression.cap()))
					setFormat(index, length, FCharFormat);
			}
			index += length;
		}
	}
}
开发者ID:Nikoli,项目名称:vacuum-im,代码行数:20,代码来源:spellhighlighter.cpp

示例14: findInFile

/**
 * The passed QRegExp is copied. Use the other findInFile function to access
 * the RegExp.
 *
 * Throws FileOpenError
 *
 * @param filename
 * @param regexp
 * @return
 */
QString findInFile (const QString &filename, const QRegExp &regexp, int group)
{
	// Make a copy because apparenly we cannot capture in a const QRegExp (but
	// we want to pass a const& so we can use an anonymous value in calls).
	QRegExp re (regexp);

	if (findInFile (filename, re))
		return re.cap (group);
	else
		return QString ();
}
开发者ID:fb,项目名称:startkladde,代码行数:21,代码来源:file.cpp

示例15: importRide

bool MetricAggregator::importRide(QDir path, RideFile *ride, QString fileName, unsigned long fingerprint, bool modify)
{
    SummaryMetrics *summaryMetric = new SummaryMetrics();
    QFile file(path.absolutePath() + "/" + fileName);

    QRegExp rx = RideFileFactory::instance().rideFileRegExp();
    if (!rx.exactMatch(fileName)) {
        return false; // not a ridefile!
    }
    summaryMetric->setFileName(fileName);
    assert(rx.numCaptures() == 7);
    QDate date(rx.cap(1).toInt(), rx.cap(2).toInt(),rx.cap(3).toInt());
    QTime time(rx.cap(4).toInt(), rx.cap(5).toInt(),rx.cap(6).toInt());
    QDateTime dateTime(date, time);

    summaryMetric->setRideDate(dateTime);
    summaryMetric->setId(ride->id());

    const RideMetricFactory &factory = RideMetricFactory::instance();
    QStringList metrics;

    for (int i = 0; i < factory.metricCount(); ++i)
        metrics << factory.metricName(i);

    // compute all the metrics
    QHash<QString, RideMetricPtr> computed = RideMetric::computeMetrics(main, ride, zones, hrzones, metrics);

    // get metrics into summaryMetric QMap
    for(int i = 0; i < factory.metricCount(); ++i) {
        // check for override
        summaryMetric->setForSymbol(factory.metricName(i), computed.value(factory.metricName(i))->value(true));
    }

    // what color will this ride be?
    QColor color = colorEngine->colorFor(ride->getTag("Calendar Text", ""));

    dbaccess->importRide(summaryMetric, ride, color, fingerprint, modify);
    delete summaryMetric;

    return true;
}
开发者ID:g3rg,项目名称:GoldenCheetah,代码行数:41,代码来源:MetricAggregator.cpp


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