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


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

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


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

示例1: cursorPositionChanged

void TextEditViewImpl::cursorPositionChanged()
{
    QTextCursor cur = textEdit.textCursor();
    std::stringstream s;
    s << cur.blockNumber()+1 << "  :  " << cur.columnNumber()+1 << "  ";
    lineLabel.setText(QString(s.str().c_str()));
}
开发者ID:hattorishizuko,项目名称:choreonoid,代码行数:7,代码来源:TextEditView.cpp

示例2: doCursorChanged

/* 光标改变时设置光标的们位置 */
void TextEditer::doCursorChanged()
{
	int row, col, tmp;
	QTextCursor cursor;
	QString str = "";

	cursor = textEdit->textCursor();	/* 获取文本中的输入光标 */
	col = cursor.columnNumber();	/* 获取列号 */
	row = textEdit->document()->blockCount();

	if (col == 0)
	{
		str = '0' + str;
	}
	while (col)
	{
		tmp = col % 10;
		col /= 10;
		str = (tmp + '0')  + str;
	}
	str = ',' + str;

	if (row == 0)
	{
		str = '0' + str;
	}
	while (row)
	{
		tmp = row % 10;
		row /= 10;
		str = (tmp + '0') + str;
	}

	statusLabelOne->setText(str);
}
开发者ID:chenpoyang,项目名称:TextEditor,代码行数:36,代码来源:textediter.cpp

示例3: do_cursorChanged

void MainWindow::do_cursorChanged()
{
    int rowNum = ui->textEdit->document()->blockCount();
    const QTextCursor cursor =ui->textEdit->textCursor();
    int colNum = cursor.columnNumber();
    first_statusLabel->setText(tr("%1 行 %2 列").arg(rowNum).arg(colNum));
}
开发者ID:flyi,项目名称:LDE,代码行数:7,代码来源:mainwindow.cpp

示例4: appendRecord

void KCDocumentRecorder::appendRecord(KCCodeEditor *editor, bool untitled)
{
    UnclosedFileStatus currentStatus;
    QTextCursor cursor;
    currentStatus.untitled=untitled;
    if(untitled)
    {
        //This will treat as a untitled file.
        QString cacheFilePath=QString(unclosedUntitledFileDir +
                                      QString::number(cacheCount++));
        //Save the file as a cache file
        editor->writeCacheFile(cacheFilePath);
        cursor=editor->getTextCursor();
        currentStatus.filePath=cacheFilePath;
    }
    else
    {
        cursor=editor->getTextCursor();
        currentStatus.filePath=editor->getFilePath();
    }
    currentStatus.horizontalCursorPosition=cursor.blockNumber();
    currentStatus.verticalCursorPosition=cursor.columnNumber();
    currentStatus.horizontalScrollPosition=editor->getHScrollValue();
    currentStatus.verticalScrollPosition=editor->getVScrollValue();
    unclosedFileInfos.prepend(currentStatus);
}
开发者ID:Kreogist,项目名称:Cuties,代码行数:26,代码来源:kcdocumentrecorder.cpp

示例5: updatePositionStatus

void TextView::updatePositionStatus() {
    QTextCursor cursor = textEdit()->textCursor();
    int line = cursor.blockNumber() + 1;
    int column = cursor.columnNumber() + 1;

    Q_EMIT status(tr("Line %1, Column %2").arg(line).arg(column));
}
开发者ID:8l,项目名称:snowman,代码行数:7,代码来源:TextView.cpp

示例6: update_cursor_position

void window::update_cursor_position()
{
	QTextCursor cursor = ui.text_edit->textCursor();
	cursor_position->setText(tr("Line: %1 Column: %2")
		.arg(ui.text_edit->toPlainText().left(cursor.position()).count("\n") + 1)
		.arg(cursor.columnNumber() + 1));
}
开发者ID:AwesomeDoesIt,项目名称:k3d,代码行数:7,代码来源:window.cpp

示例7: eventFilter

bool ExpressionQueryWidget::eventFilter(QObject *obj, QEvent *event)
{
    if (obj == m_textEdit) {
        switch (event->type()) {
            case QEvent::KeyPress:
            {
                QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
                int key = keyEvent->key();
                if (key == Qt::Key_Return || key == Qt::Key_Enter) {
                    executeExpression();
                    return true;
                } else if (key == Qt::Key_Backspace) {
                    // ensure m_expr doesn't contain backspace characters
                    QTextCursor cursor = m_textEdit->textCursor();
                    bool atLastLine = !(cursor.block().next().isValid());
                    if (!atLastLine)
                        return true;
                    if (cursor.columnNumber() <= m_prompt.count())
                        return true;
                    cursor.deletePreviousChar();
                    m_expr = cursor.block().text().mid(m_prompt.count());
                    return true;
                } else {
                    m_textEdit->moveCursor(QTextCursor::End);
                    m_expr += keyEvent->text();
                }
                break;
            }
            case QEvent::FocusIn:
                checkCurrentContext();
                m_textEdit->moveCursor(QTextCursor::End);
                break;
            default:
                break;
        }
    } else if (obj == m_lineEdit) {
        switch (event->type()) {
            case QEvent::KeyPress:
            {
                QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
                int key = keyEvent->key();
                if (key == Qt::Key_Up && m_lineEdit->text() != m_lastExpr) {
                    m_expr = m_lineEdit->text();
                    if (!m_lastExpr.isEmpty())
                        m_lineEdit->setText(m_lastExpr);
                } else if (key == Qt::Key_Down) {
                    m_lineEdit->setText(m_expr);
                }
                break;
            }
            case QEvent::FocusIn:
                checkCurrentContext();
                break;
            default:
                break;
        }
    }
    return QWidget::eventFilter(obj, event);
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:59,代码来源:expressionquerywidget.cpp

示例8: executeQuery

void QueryPanel::executeQuery() {
    QTextCursor c = editor->textCursor();
    QString stmt = getActiveStatement(c.blockNumber(), c.columnNumber());
    error->hide();
    status->hide();
    model->setQuery(stmt);
    model->select();
}
开发者ID:ohwgiles,项目名称:sequeljoe,代码行数:8,代码来源:querypanel.cpp

示例9: doCursorChanged

/*
 * 函数名称:捕获鼠标改变
 * 函数功能:当光标的位置改变时,更新状态栏页、列信息
 */
void QJDTextBrowser::doCursorChanged()
{
    int pageNum=ui->textEdit->document()->pageCount();//页计数
    const QTextCursor cursor=ui->textEdit->textCursor();//获取当前的可见光标
    int colNum=cursor.columnNumber();//列计数
    int rowNum=ui->textEdit->document()->blockCount();// 行计数
    ui->label_1->setText(tr("Page:%1 Line:%2 Col:%3").arg(pageNum).arg(rowNum).arg(colNum));
}
开发者ID:xtfllbl,项目名称:Flow2,代码行数:12,代码来源:qjdtextbrowser.cpp

示例10: doCursorChanged

void CMainWindow::doCursorChanged()
{
	int pageNum = textEdit->document()->pageCount();
	const QTextCursor cursor = textEdit->textCursor();
	int colNum = cursor.columnNumber();
	int rowNum = textEdit->document()->blockCount();	
	label1->setText(tr("%1 页	%3 列").arg(pageNum).arg(colNum));
}
开发者ID:hkutangyu,项目名称:QTDemo,代码行数:8,代码来源:mainwindow.cpp

示例11: slotCursorPosChanged

/*!
 * \brief TextDoc::slotCursorPosChanged update status bar with line:column
 */
void TextDoc::slotCursorPosChanged()
{
  QTextCursor pos = textCursor();
  int x = pos.blockNumber();
  int y = pos.columnNumber();
  emit signalCursorPosChanged(x+1, y+1);
  tmpPosX = x;
  tmpPosY = y;
}
开发者ID:NextGenIntelligence,项目名称:qucs,代码行数:12,代码来源:textdoc.cpp

示例12: slotCursorPosChanged

/*!
 * \brief TextDoc::slotCursorPosChanged update status bar with line:column
 */
void TextDoc::slotCursorPosChanged()
{
  QTextCursor pos = textCursor();
  int x = pos.blockNumber();
  int y = pos.columnNumber();
  App->printCursorPosition(x+1, y+1);
  tmpPosX = x;
  tmpPosY = y;
}
开发者ID:mdavidsaver,项目名称:qucs,代码行数:12,代码来源:textdoc.cpp

示例13: insertParagraphSeparator

QString MatchingText::insertParagraphSeparator(const QTextCursor &tc) const
{
    BackwardsScanner tk(tc, QString(), MAX_NUM_LINES);
    int index = tk.startToken();

    if (tk[index - 1].isNot(T_LBRACE))
        return QString(); // nothing to do.

    const QString textBlock = tc.block().text().mid(tc.columnNumber()).trimmed();
    if (! textBlock.isEmpty())
        return QString();

    --index; // consume the `{'

    const SimpleToken &token = tk[index - 1];

    if (token.is(T_STRING_LITERAL) && tk[index - 2].is(T_EXTERN)) {
        // recognized extern "C"
        return QLatin1String("}");

    } else if (token.is(T_IDENTIFIER)) {
        int i = index - 1;

        forever {
            const SimpleToken &current = tk[i - 1];

            if (current.is(T_EOF_SYMBOL))
                break;

            else if (current.is(T_CLASS) || current.is(T_STRUCT) || current.is(T_UNION) || current.is(T_ENUM)) {
                // found a class key.
                QString str = QLatin1String("};");

                if (shouldInsertNewline(tc))
                    str += QLatin1Char('\n');

                return str;
            }

            else if (current.is(T_NAMESPACE))
                return QLatin1String("}"); // found a namespace declaration

            else if (current.is(T_SEMICOLON))
                break; // found the `;' sync token

            else if (current.is(T_LBRACE) || current.is(T_RBRACE))
                break; // braces are considered sync tokens

            else if (current.is(T_LPAREN) || current.is(T_RPAREN))
                break; // sync token

            else if (current.is(T_LBRACKET) || current.is(T_RBRACKET))
                break; // sync token

            --i;
        }
    }
开发者ID:asokolov,项目名称:ananas-creator,代码行数:57,代码来源:MatchingText.cpp

示例14: sIgnoreWord

void XTextEdit::sIgnoreWord()
{
    QTextCursor cursor = cursorForPosition(_lastPos);
    QString textBlock = cursor.block().text();
    int pos = cursor.columnNumber();
    int end = textBlock.indexOf(QRegExp("\\W+"),pos);
    int begin = textBlock.left(pos).lastIndexOf(QRegExp("\\W+"),pos);
    textBlock = textBlock.mid(begin+1,end-begin-1);
    _guiClientInterface->hunspell_ignore(textBlock);
    _highlighter->rehighlight();
}
开发者ID:ChristopherCotnoir,项目名称:qt-client,代码行数:11,代码来源:xtextedit.cpp

示例15: cursorPositionChanged

void MdiChild::cursorPositionChanged()
{
	QTextCursor cursor      = this->textCursor();

	// Current line text
	//QString cur_line_text   = cursor.block().text().trimmed();

	std::ostringstream oss;
	oss <<"Line:"<< cursor.blockNumber()+1 <<"  Colum:"<<cursor.columnNumber();
	statusBar->showMessage( QString::fromStdString(oss.str()));

}
开发者ID:cooltype,项目名称:Compilers,代码行数:12,代码来源:mdichild.cpp


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