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


C++ QTextCursor::position方法代码示例

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


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

示例1: isPropriety

bool RtfCssEditor::isPropriety() {
  QTextCursor tc = textCursor();
  int currentPos = tc.position();
  tc.select(QTextCursor::LineUnderCursor);
  QString line = tc.selectedText();
  tc.movePosition(QTextCursor::StartOfLine);
  int startposition = tc.position();

  tc.setPosition(currentPos);
  if ((line.indexOf(':') > 2) && (startposition + line.indexOf(':') < currentPos)) {
    if ((line.indexOf(';') != -1) && (startposition + line.indexOf(';') >= currentPos)) {
      return true;
    }
    else if (line.indexOf(';') == -1) {
      return true;
    }
  }
  return false;
}
开发者ID:Elv13,项目名称:Kimberlite,代码行数:19,代码来源:rtfCssEditor.cpp

示例2: getSelectedAddr

QString DataWidget::getSelectedAddr() {
    if (!isEnabled()) {
        return QStringLiteral("000000");
    }
    QTextCursor c = textCursor();
    c.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor);
    c.setPosition(c.position()+6, QTextCursor::KeepAnchor); // +6 == size of the address
                                                            // See MainWindow::drawNextDisassembleLine() for details
    return c.selectedText();
}
开发者ID:zdimension,项目名称:CEmu,代码行数:10,代码来源:datawidget.cpp

示例3: addCheckmark

void NoteEditorUtils::addCheckmark(QTextCursor &cursor)
{
    static const QChar unicode[] = {0x2713};
    const int size = sizeof(unicode) / sizeof(QChar);
    const int position = cursor.position();
    cursor.movePosition(QTextCursor::StartOfLine);
    const QString checkMark = QString::fromRawData(unicode, size);
    cursor.insertText(checkMark);
    cursor.setPosition(position + checkMark.size());
}
开发者ID:KDE,项目名称:kjots,代码行数:10,代码来源:noteeditorutils.cpp

示例4: prompt

void PythonTypeIn::prompt(bool storeOnly)
{
    const char * c = storeOnly ? "...> " : "py> ";
    commandPrompt_ = c;
    append(c);

    QTextCursor tc = textCursor();
    tc.movePosition(QTextCursor::End);
    tail_ = tc.position();
}
开发者ID:alejandrozuleta,项目名称:DisplayCluster,代码行数:10,代码来源:PythonConsole.cpp

示例5: mousePressEvent

void LineIndicator::mousePressEvent( QMouseEvent *e )
{
    QTextCursor cursor = mEditor->cursorForPosition(QPoint(0, e->pos().y()));
    if(cursor.isNull()) {
        mLastCursorPos = -1;
        return;
    }
    mEditor->setTextCursor(cursor);
    mLastCursorPos = cursor.position();
}
开发者ID:DSastre,项目名称:supercollider,代码行数:10,代码来源:line_indicator.cpp

示例6: LimitCursorSelectionTo

void ConsoleWidget::LimitCursorSelectionTo(int start)
{
    QTextCursor cursor = textCursor();
    int anchor = cursor.anchor(), position = cursor.position();
    if (anchor != position && (anchor < start || position < start))
    {
        cursor.setPosition(qMax(start, anchor), QTextCursor::MoveAnchor);
        cursor.setPosition(qMax(start, position), QTextCursor::KeepAnchor);
        setTextCursor(cursor);
    }
}
开发者ID:TeamKami,项目名称:KamiCmd,代码行数:11,代码来源:ConsoleWidget.cpp

示例7: onContentsChanged

void SchematicName::onContentsChanged() {
  QString text       = document()->toPlainText();
  QTextCursor cursor = textCursor();
  int position       = cursor.position();
  if (position > 0 && text.at(position - 1) == '\n') {
    text.remove("\n");
    setPlainText(text);
    ;
    emit focusOut();
  }
}
开发者ID:opentoonz,项目名称:opentoonz,代码行数:11,代码来源:schematicnode.cpp

示例8: mousePressEvent

void QConsoleWidget::mousePressEvent(
        QMouseEvent *e
        ) {
    //TODO: mousepressevent

    int eval_index;
    bool haveDone_;

    {
        QTextCursor tc = this->textCursor();
        if (tc.hasSelection()) {
            auto se = tc.selectionEnd();
            auto sb = tc.selectionStart();
            if (sb >= promptEndPos_) { eval_index = 0;/*rw*/ }
            else if (se <= promptEndPos_) { eval_index = 1;/*r*/ }
            else {
                eval_index = 2/*a*/;
            }
        }
        else {
            if (e->button()&Qt::RightButton) {
                auto tc_ = this->cursorForPosition(e->pos());
                this->setTextCursor(tc_);
            }
            auto pos_ =  tc.position();
            if (pos_>=this->promptEndPos_) {
                eval_index = 3;//read write
            }
            else {
                if (pos_>=this->promptBeginPos_) {
                    QTextCursor tc = this->textCursor();
                    tc.setPosition( this->promptEndPos_ );
                    this->setTextCursor(tc);
                    eval_index = 3;//read write
                }
                else {
                    eval_index = 4;//read only
                }
            }
        }
    }

    switch (eval_index)
    {
    case 0: haveDone_ = _pf<bool, SelectMousePressedReadWrite>(this,e); break;
    case 1: haveDone_ = _pf<bool, SelectMousePressedReadOnly>(this, e); break;
    case 2: haveDone_ = _pf<bool, SelectMousePressedAll>(this, e); break;
    case 3: haveDone_ = _pf<bool, MousePressedReadWrite>(this, e); break;
    case 4: haveDone_ = _pf<bool, MousePressedReadOnly>(this, e); break;
    }

    if (haveDone_) { return; }
    return TP::mousePressEvent(e);
}
开发者ID:ngzHappy,项目名称:QtLuaConsole,代码行数:54,代码来源:QConsoleWidget.cpp

示例9:

QPair<int, int>  KoTextInlineRdf::findExtent()
{
    if (d->bookmark && d->document) {
        KoBookmark *e = d->bookmark->endBookmark();
        return QPair<int, int>(d->bookmark->position(), e->position());
    }
    if (d->kotextmeta && d->document) {
        KoTextMeta *e = d->kotextmeta->endBookmark();
        if (!e) {
            return QPair<int, int>(0, 0);
        }
        return QPair<int, int>(d->kotextmeta->position(), e->position());
    }
    if (d->cell.isValid() && d->document) {
        QTextCursor b = d->cell.firstCursorPosition();
        QTextCursor e = d->cell.lastCursorPosition();
        return QPair<int, int>(b.position(), e.position());
    }
    return QPair<int, int>(0, 0);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:20,代码来源:KoTextInlineRdf.cpp

示例10: object

QString KoTextInlineRdf::object()
{
    if (d->isObjectAttriuteUsed) {
        return d->object;
    }
    if (d->bookmark && d->document) {
        KoBookmark *e = d->bookmark->endBookmark();
        QTextCursor cursor(d->document);

        cursor.setPosition(d->bookmark->position(), QTextCursor::MoveAnchor);
        cursor.setPosition(e->position(), QTextCursor::KeepAnchor);
        QString ret = cursor.QTextCursor::selectedText();
        return ret.remove(QChar::ObjectReplacementCharacter);
    }
    if (d->kotextmeta && d->document) {
        KoTextMeta *e = d->kotextmeta->endBookmark();
        QTextCursor cursor(d->document);

        if (!e) {
            kDebug(30015) << "Broken KoTextMeta, no end tag found!";
            return QString();
        } else {
            cursor.setPosition(d->kotextmeta->position(), QTextCursor::MoveAnchor);
            cursor.setPosition(e->position(), QTextCursor::KeepAnchor);
            QString ret = cursor.selectedText();
            return ret.remove(QChar::ObjectReplacementCharacter);
        }
    }
    if (d->cell.isValid() && d->document) {
        QTextCursor b = d->cell.firstCursorPosition();
        QTextCursor e = d->cell.lastCursorPosition();

        QTextCursor cursor(d->document);
        cursor.setPosition(b.position(), QTextCursor::MoveAnchor);
        cursor.setPosition(e.position(),  QTextCursor::KeepAnchor);
        QString ret = cursor.selectedText();
        return ret.remove(QChar::ObjectReplacementCharacter);
    }

    return d->block.text();
}
开发者ID:KDE,项目名称:calligra-history,代码行数:41,代码来源:KoTextInlineRdf.cpp

示例11: findEditor

QTextCursor FindEditor::findEditor(QTextDocument *doc, const QTextCursor &cursor, FindOption *opt, bool wrap)
{
    int from = cursor.position();
    if (cursor.hasSelection()) {
        if (opt->backWard) {
            from = cursor.selectionStart();
        } else {
            from = cursor.selectionEnd();
        }
    }
    return findEditorHelper(doc,from,opt,wrap);
}
开发者ID:visualfc,项目名称:liteide,代码行数:12,代码来源:findeditor.cpp

示例12: tabShouldIndent

bool TabSettings::tabShouldIndent(const QTextDocument *document, QTextCursor cursor, int *suggestedPosition) const
{
    if (m_tabKeyBehavior == TabNeverIndents)
        return false;
    QTextCursor tc = cursor;
    if (suggestedPosition)
        *suggestedPosition = tc.position(); // At least suggest original position
    tc.movePosition(QTextCursor::StartOfLine);
    if (tc.atBlockEnd()) // cursor was on a blank line
        return true;
    if (document->characterAt(tc.position()).isSpace()) {
        tc.movePosition(QTextCursor::WordRight);
        if (tc.columnNumber() >= cursor.columnNumber()) {
            if (suggestedPosition)
                *suggestedPosition = tc.position(); // Suggest position after whitespace
            if (m_tabKeyBehavior == TabLeadingWhitespaceIndents)
                return true;
        }
    }
    return (m_tabKeyBehavior == TabAlwaysIndents);
}
开发者ID:halsten,项目名称:beaverdbg,代码行数:21,代码来源:tabsettings.cpp

示例13: from_pos

static void from_pos(CTEXTAREA *_object, int pos, int *par, int *car)
{
	QTextCursor cursor = WIDGET->textCursor();
	
	if (pos >= get_length(THIS))
		cursor.movePosition(QTextCursor::End);
	else
		cursor.setPosition(pos);
	
	*par = cursor.blockNumber();
	*car = cursor.position() - cursor.block().position();
}
开发者ID:ramonelalto,项目名称:gambas,代码行数:12,代码来源:CTextArea.cpp

示例14: wordUnderCursor

QString GLSLTextEditorWidget::wordUnderCursor() const
{
    QTextCursor tc = textCursor();
    const QChar ch = characterAt(tc.position() - 1);
    // make sure that we're not at the start of the next word.
    if (ch.isLetterOrNumber() || ch == QLatin1Char('_'))
        tc.movePosition(QTextCursor::Left);
    tc.movePosition(QTextCursor::StartOfWord);
    tc.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
    const QString word = tc.selectedText();
    return word;
}
开发者ID:KDE,项目名称:android-qt-creator,代码行数:12,代码来源:glsleditor.cpp

示例15: enableOutput

void Console::enableOutput()
{
    if(_ioDevice){
        setPlainText( toPlainText() + _ioDevice->readAll());
        setEnabled(true);

        QTextCursor cursor = textCursor();
        cursor.movePosition(QTextCursor::End);
        setTextCursor(cursor);
        _lastCursorPos = cursor.position();
    }
}
开发者ID:intelligide,项目名称:UnicornEdit,代码行数:12,代码来源:Console.cpp


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