本文整理汇总了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;
}
示例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();
}
示例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());
}
示例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();
}
示例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();
}
示例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);
}
}
示例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();
}
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
}