本文整理汇总了C++中cursorRect函数的典型用法代码示例。如果您正苦于以下问题:C++ cursorRect函数的具体用法?C++ cursorRect怎么用?C++ cursorRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cursorRect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: textCursor
void RtfCssEditor::insertBrace() {
if (c->widget() != this)
return;
QTextCursor tc = textCursor();
int currentPos = tc.position();
tc.movePosition(QTextCursor::Down);
tc.select(QTextCursor::LineUnderCursor);
if (tc.selectedText().isEmpty() == true) {
tc.setPosition(currentPos);
//if (QTextCursor::NextWord)
tc.insertText("\n \n}");
/*tc.movePosition(QTextCursor::Left);
tc.movePosition(QTextCursor::Left);*/
tc.movePosition(QTextCursor::Left);
tc.movePosition(QTextCursor::Left);
setTextCursor(tc);
QRect cr = cursorRect();
cr.setWidth(c->popup()->sizeHintForColumn(0) + c->popup()->verticalScrollBar()->sizeHint().width());
c->complete(cr); // popup it up!
}
else {
tc.setPosition(currentPos);
tc.insertText("\n ");
}
tc.movePosition(QTextCursor::EndOfWord);
QRect cr = cursorRect();
cr.setWidth(c->popup()->sizeHintForColumn(0) + c->popup()->verticalScrollBar()->sizeHint().width());
c->complete(cr); // popup it up!
}
开发者ID:Elv13,项目名称:Kimberlite,代码行数:30,代码来源:rtfCssEditor.cpp
示例2: Q_UNUSED
void QEglFSCursor::changeCursor(QCursor *cursor, QWindow *window)
{
Q_UNUSED(window);
const QRect oldCursorRect = cursorRect();
if (setCurrentCursor(cursor))
update(oldCursorRect | cursorRect());
}
开发者ID:FlavioFalcao,项目名称:qt5,代码行数:7,代码来源:qeglfscursor.cpp
示例3: qDebug
/** Redefined to be able to move TagButton when typing. */
void TagLineEdit::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right) {
/// TODO cursorWordForward / cursorWordBackard to stop on TagButton
if (QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier)) {
qDebug() << "cursorWordForward / backward";
}
LineEdit::keyPressEvent(event);
for (TagButton *t : _tags) {
if (t->frameGeometry().contains(cursorRect().center())) {
if (event->key() == Qt::Key_Left) {
cursorBackward(false, t->spaceCount() - 1);
} else {
cursorForward(false, t->spaceCount() - 1);
}
break;
}
}
} else {
QString k = event->text();
int w = fontMetrics().width(k);
if (event->key() == Qt::Key_Delete) {
qDebug() << Q_FUNC_INFO << "Key_Delete";
w = -w;
}
for (TagButton *t : _tags) {
if (t->frameGeometry().x() > cursorRect().center().x()) {
t->move(t->x() + w, 0);
}
}
LineEdit::keyPressEvent(event);
}
}
开发者ID:percevall,项目名称:Miam-Player,代码行数:34,代码来源:taglineedit.cpp
示例4: cursorRect
/** TagButton instances are converted with whitespaces in the LineEdit in order to move them. */
void TagLineEdit::insertSpaces()
{
TagButton *t = qobject_cast<TagButton*>(sender());
int cx = cursorRect().x();
t->setPosition(cursorPosition());
int numberOfSpace = 2;
this->setText(this->text().insert(cursorPosition(), " "));
cursorForward(false, 2);
while (t->frameGeometry().contains(cursorRect().center())) {
this->setText(this->text().insert(cursorPosition(), " "));
cursorForward(false);
numberOfSpace++;
}
t->setMinimumWidth(numberOfSpace * fontMetrics().width(" ") - 5);
t->setSpaceCount(numberOfSpace);
t->disconnect();
for (TagButton *tag : _tags) {
//qDebug() << Q_FUNC_INFO << "trying to move tag";
if (t != tag && tag->frameGeometry().x() > cx) {
//qDebug() << Q_FUNC_INFO << "moving tag" << tag->text();
tag->move(tag->x() + fontMetrics().width(" ") * numberOfSpace, 0);
}
}
}
开发者ID:percevall,项目名称:Miam-Player,代码行数:28,代码来源:taglineedit.cpp
示例5: cursorRect
void QEGLPlatformCursor::setPos(const QPoint &pos)
{
QGuiApplicationPrivate::inputDeviceManager()->setCursorPos(pos);
const QRect oldCursorRect = cursorRect();
m_cursor.pos = pos;
update(oldCursorRect | cursorRect());
m_screen->handleCursorMove(m_cursor.pos);
}
开发者ID:James-intern,项目名称:Qt,代码行数:8,代码来源:qeglplatformcursor.cpp
示例6: cursorRect
void QEglFSCursor::pointerEvent(const QMouseEvent &event)
{
if (event.type() != QEvent::MouseMove)
return;
const QRect oldCursorRect = cursorRect();
m_cursor.pos = event.pos();
update(oldCursorRect | cursorRect());
}
开发者ID:FlavioFalcao,项目名称:qt5,代码行数:8,代码来源:qeglfscursor.cpp
示例7: textCursor
void TextEdit::keyPressEvent(QKeyEvent *e){
QTextEdit::keyPressEvent(e);
if (completationOpen) return; // don't open a second completationbox
QTextCursor cursor = textCursor();
QChar rchar = cursor.block().text()[cursor.position() - cursor.block().position()];
if (!rchar.isLetterOrNumber()){
//request a new completation list
QString lstring = cursor.block().text().left(cursor.position() - cursor.block().position());
parent->requestCompletationList(lstring);
QString last = lstring.split(QRegExp("\\W")).last();
//open the completationbox if the list has more than one entry
if(parent->completationList.count() != 0 && !rchar.isLetterOrNumber() ){;
QWidget *box = new CompletionBox(this, parent->completationList, last.left(last.length() - parent->completationOffset -1));
box->move(mapToGlobal(cursorRect().bottomLeft()));
box->show();
connect(parent,SIGNAL(HelpStringSignal(const QString&)),box,SLOT(setHelpString(const QString&)));
connect(box,SIGNAL(requestHelpString(const QString&)), parent, SLOT(emitRequestHelpString(const QString&)));
}
}
}
开发者ID:4DA,项目名称:lumina-ng,代码行数:25,代码来源:sourceedit.cpp
示例8: textCursor
void TextEdit::insertCompletion(const QString& completion)
{
QTextCursor tc = textCursor();
int extra = completion.length() - c->completionPrefix().length();
QString s = completion.right(extra);
if (s.endsWith("*") ) {
s.chop(1);
}
DomModel* mymodel = dommodel();
if ( !s.contains("operacion:") ) {
s = mymodel->prefix()+ s + mymodel->suffix();
}
tc.insertText(s+" ");
QRect cr = cursorRect();
//marcador
setTextCursor(tc);
showFromWidget(cr, s );
updateDockSbMenu();
}
开发者ID:Cenditel,项目名称:pysafet,代码行数:29,代码来源:textedit.cpp
示例9: cursorRect
QRect SourceEdit::lineRect()
{
QRect rect = cursorRect();
rect.setLeft(0);
rect.setWidth(viewport()->width());
return rect;
}
开发者ID:dgu123,项目名称:qshaderedit,代码行数:7,代码来源:editor.cpp
示例10: p
/** Redefined to display user input like closable "bubbles". */
void TagLineEdit::paintEvent(QPaintEvent *)
{
QStylePainter p(this);
// Draw frame
QStyleOptionFrameV3 frame;
this->initStyleOption(&frame);
QPalette palette = QApplication::palette();
p.setPen(palette.mid().color());
p.setBrush(palette.base());
p.drawRect(this->rect().adjusted(0, 0, -1, -1));
// Compute cursor position
QRect contentsRect = this->style()->subElementRect(QStyle::SE_LineEditContents, &frame);
QRect rText = contentsRect.adjusted(2, 0, 0, 0);
if (!_tags.isEmpty() || (placeholderText().isEmpty() || (!placeholderText().isEmpty() && hasFocus()))) {
p.setPen(palette.text().color());
p.drawText(rText, Qt::AlignLeft | Qt::AlignVCenter, text());
// Animate cursor is focus is owned by this widget
bool overlap = false;
for (TagButton *t : _tags) {
if (t->frameGeometry().contains(cursorRect().center())) {
overlap = true;
break;
}
}
if (!overlap && hasFocus()) {
this->drawCursor(&p, rText.adjusted(0, 1, 0, -1));
}
} else {
p.setPen(palette.mid().color());
p.drawText(rText, Qt::AlignLeft | Qt::AlignVCenter, placeholderText());
}
}
开发者ID:percevall,项目名称:Miam-Player,代码行数:36,代码来源:taglineedit.cpp
示例11: TagButton
void TagLineEdit::addTag(const QString &tag, int column)
{
if (tag.trimmed().isEmpty()) {
return;
}
for (TagButton *button : _tags) {
if (button->text() == tag.trimmed().toLower()) {
// It useless to add a tag more than once (IMHO)
return;
}
}
TagButton *t = new TagButton(tag.trimmed(), this);
if (column != -1) {
t->setColumn(column);
}
t->setMaximumHeight(this->height() - 2);
// Move all tag buttons, next to the one that is about to be closed, to the left
connect(t->closeButton(), &QToolButton::clicked, this, [=]() {
this->closeTagButton(t);
});
_tags.append(t);
this->setFocus();
// Unfortunately, we have to wait that a QShowEvent is emitted to have correct size of the Widget
connect(t, &TagButton::shown, this, &TagLineEdit::insertSpaces);
t->move(cursorRect().right() + 1, 0);
t->show();
}
开发者ID:percevall,项目名称:Miam-Player,代码行数:31,代码来源:taglineedit.cpp
示例12: QFontMetrics
void TikzEditor::printWhiteSpaces(QPainter &painter)
{
const QFontMetrics fontMetrics = QFontMetrics(document()->defaultFont());
for (QTextBlock block = firstVisibleBlock(); block.isValid(); block = block.next())
{
if (blockBoundingGeometry(block).top() > viewport()->height())
break;
const QString text = block.text();
const int textLength = text.length();
for (int i = 0; i < textLength; ++i)
{
QTextCursor cursor = textCursor();
cursor.setPosition(block.position() + i, QTextCursor::MoveAnchor);
const QRect rect = cursorRect(cursor);
// const QFontMetrics fontMetrics = QFontMetrics(cursor.charFormat().font());
if (m_showWhiteSpaces && text.at(i) == ' ')
paintSpace(painter, rect.x() + spaceWidth() / 2.0, rect.y() + fontMetrics.height() / 2.0);
else if (m_showTabulators && text.at(i) == '\t')
paintTabstop(painter, rect.x() + spaceWidth() / 2.0, rect.y() + fontMetrics.height() / 2.0);
}
}
}
开发者ID:jfmcarreira,项目名称:ktikz-old,代码行数:27,代码来源:tikzeditor.cpp
示例13: textCursor
void TikzEditor::highlightCurrentLine()
{
/*
// this hides the white space and tab marks on the current line :-(
QList<QTextEdit::ExtraSelection> extraSelections;
if (!isReadOnly())
{
QTextEdit::ExtraSelection selection;
selection.format.setBackground(m_highlightCurrentLineColor);
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
selection.cursor = textCursor();
selection.cursor.clearSelection();
extraSelections.append(selection);
}
setExtraSelections(extraSelections);
// highlight the currently selected brackets (if any)
matchBrackets();
*/
// update the area covering the previously highlighted line (updating the whole viewport is too slow :-( )
m_previousHighlightedLine.moveTop(m_previousHighlightedLine.top() - (verticalScrollBar()->value() - m_oldVerticalScrollBarValue + 0.5) * m_previousHighlightedLine.height());
m_previousHighlightedLine.setHeight(2 * m_previousHighlightedLine.height()); // should be large enough to cover the previous line (ugly hack :-( )
viewport()->update(m_previousHighlightedLine);
// update the area covering the currently highlighted line
QRect rect = cursorRect();
rect.setX(0);
rect.setWidth(viewport()->width());
viewport()->update(rect);
m_previousHighlightedLine = rect;
m_oldVerticalScrollBarValue = verticalScrollBar()->value();
}
开发者ID:jfmcarreira,项目名称:ktikz-old,代码行数:34,代码来源:tikzeditor.cpp
示例14: textUnderCursor
void WizTitleEdit::onTextEdit(const QString& text)
{
if (!c)
return;
QString completionPrefix = textUnderCursor();
bool isSeparator = (!completionPrefix.isEmpty() || charBeforeCursor() == m_separator) ? true : false;
if (!isSeparator) {
c->popup()->hide();
return;
}
static QString eow("~!#$%^&*()_+{}|:\"<>?,./;'[]\\-="); // end of word
if (!isSeparator && (text.isEmpty()
|| eow.contains(text.right(1)))) {
c->popup()->hide();
return;
}
if (completionPrefix != c->completionPrefix()) {
updateCompleterPopupItems(completionPrefix);
}
QRect cr = cursorRect();
cr.setWidth(c->popup()->sizeHintForColumn(0)
+ c->popup()->verticalScrollBar()->sizeHint().width() + 20); // bigger
c->complete(cr); // popup it up!
}
开发者ID:WizTeam,项目名称:WizQTClient,代码行数:31,代码来源:WizTitleEdit.cpp
示例15: viewport
void TextEditor::paintEvent(QPaintEvent *e) {
int width = viewport()->width(), height = fontMetrics().height();
QRect cRect(0, cursorRect().y(), viewport()->width(), height);
const int cursorPos = textCursor().block().position();
QPainter p(viewport());
// good for highlighting line during paused execution:
p.fillRect(cRect, QBrush(QColor(215, 227, 255)));
if (m_pc != NULL && m_program->getStatus() == PAUSED) {
QColor highlightColor = QColor(255, 240, 117); // yellow
highlightLine(p, m_pc, highlightColor, width, height);
// highlightColor = highlightColor.lighter(105);
// cerr << "<<<Painting: size = " << m_lastInstructions.size() << endl;
foreach(ParseNode *parseNode, m_lastInstructions) {
highlightColor = highlightColor.lighter(120);
if (highlightColor == Qt::white) {
//cerr << "\t" << i << " painted!\n";
break;
}
if (!parseNode->isValid())
continue;
const QTextBlock *block = parseNode->getTextBlock();
if (block != NULL && block->isValid() && parseNode != m_pc && cursorPos != block->position())
highlightLine(p, parseNode, highlightColor, width, height);
}
开发者ID:endrift,项目名称:mipscope,代码行数:29,代码来源:TextEditor.cpp
示例16: switch
void LineEdit::keyPressEvent (QKeyEvent *e)
{
if (c && c->popup()->isVisible()) {
// The following keys are forwarded by the completer to the widget
switch (e->key()) {
case Qt::Key_Enter:
case Qt::Key_Return:
case Qt::Key_Escape:
case Qt::Key_Tab:
case Qt::Key_Backtab:
e->ignore();
return; // let the completer do default behavior
default:
break;
}
}
bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_E); // CTRL+E
if ((e->key () == Qt::Key_Enter) || (e->key () == Qt::Key_Return)) {
e->ignore ();
emit returnPressed();
return;
}
if (!c || !isShortcut) // do not process the shortcut when we have a completer
QTextEdit::keyPressEvent(e);
const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier);
if (!c || (ctrlOrShift && e->text().isEmpty()))
return;
static QString eow("[email protected]#$%^&*()_+{}|:\"<>?,./;'[]\\-="); // end of word
bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift;
QString completionPrefix = textUnderCursor();
if (!isShortcut && (hasModifier || e->text().isEmpty()|| completionPrefix.length() < 2
|| eow.contains(e->text().right(1)))) {
c->popup()->hide();
return;
}
if (completionPrefix != c->completionPrefix()) {
c->setCompletionPrefix(completionPrefix);
c->popup()->setCurrentIndex(c->completionModel()->index(0, 0));
}
QRect cr = cursorRect();
cr.setWidth(c->popup()->sizeHintForColumn(0)
+ c->popup()->verticalScrollBar()->sizeHint().width());
c->complete(cr); // popup it up!
/*
if ((e->key () == Qt::Key_Enter) || (e->key () == Qt::Key_Return)) {
e->ignore ();
emit returnPressed();
}
else
QTextEdit::keyPressEvent (e);
*/
}
开发者ID:DBoo,项目名称:fix8logviewer,代码行数:58,代码来源:lineedit.cpp
示例17: while
//-----------------------------------------------------------------------------
void PythonQtScriptingConsole::handleTabCompletion()
{
QTextCursor textCursor = this->textCursor();
int pos = textCursor.position();
textCursor.setPosition(commandPromptPosition());
textCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
int startPos = textCursor.selectionStart();
int offset = pos-startPos;
QString text = textCursor.selectedText();
QString textToComplete;
int cur = offset;
while(cur--) {
QChar c = text.at(cur);
if (c.isLetterOrNumber() || c == '.' || c == '_') {
textToComplete.prepend(c);
} else {
break;
}
}
QString lookup;
QString compareText = textToComplete;
int dot = compareText.lastIndexOf('.');
if (dot!=-1) {
lookup = compareText.mid(0, dot);
compareText = compareText.mid(dot+1, offset);
}
if (!lookup.isEmpty() || !compareText.isEmpty()) {
compareText = compareText.toLower();
QStringList found;
QStringList l = PythonQt::self()->introspection(_context, lookup, PythonQt::Anything);
foreach (QString n, l) {
if (n.toLower().startsWith(compareText)) {
found << n;
}
}
if (!found.isEmpty()) {
_completer->setCompletionPrefix(compareText);
_completer->setCompletionMode(QCompleter::PopupCompletion);
_completer->setModel(new QStringListModel(found, _completer));
_completer->setCaseSensitivity(Qt::CaseInsensitive);
QTextCursor c = this->textCursor();
c.movePosition(QTextCursor::StartOfWord);
QRect cr = cursorRect(c);
cr.setWidth(_completer->popup()->sizeHintForColumn(0)
+ _completer->popup()->verticalScrollBar()->sizeHint().width());
cr.translate(0,8);
_completer->complete(cr);
} else {
_completer->popup()->hide();
}
} else {
开发者ID:AlphaStaxLLC,项目名称:TundraAddons,代码行数:57,代码来源:PythonQtScriptingConsole.cpp
示例18: switch
void MimeTextEdit::keyPressEvent(QKeyEvent *e)
{
if (mCompleter && mCompleter->popup()->isVisible()) {
// The following keys are forwarded by the completer to the widget
switch (e->key()) {
case Qt::Key_Enter:
case Qt::Key_Return:
case Qt::Key_Escape:
case Qt::Key_Tab:
case Qt::Key_Backtab:
mCompleter->popup()->hide();
mForceCompleterShowNextKeyEvent=false;
e->ignore();
return; // let the completer do default behavior
default:
break;
}
}
bool isShortcut = ((e->modifiers() & mCompleterKeyModifiers) && e->key() == mCompleterKey);
if (isShortcut && !mForceCompleterShowNextKeyEvent) {
mCompleterStartString.clear();
}
isShortcut |= mForceCompleterShowNextKeyEvent;
if (!mCompleter || !isShortcut) // do not process the shortcut when we have a completer
QTextEdit::keyPressEvent(e);
if (!mCompleter) return; //Nothing else to do if not mCompleter initialized
if (!isShortcut && (mCompleter && !mCompleter->popup()->isVisible())) {
return;
}
if (!mForceCompleterShowNextKeyEvent) {
static QString eow(" [email protected]#$%^&*()_+{}|:\"<>?,./;'[]\\-="); // end of word
if (!isShortcut && !e->text().isEmpty() && eow.contains(e->text())){
mCompleter->popup()->hide();
return;
}
}
QString completionPrefix = textUnderCursor();
if (completionPrefix != mCompleter->completionPrefix()) {
mCompleter->setCompletionPrefix(completionPrefix);
mCompleter->popup()->setCurrentIndex(mCompleter->completionModel()->index(0, 0));
}
QRect cr = cursorRect();
cr.setWidth(mCompleter->popup()->sizeHintForColumn(0) + mCompleter->popup()->verticalScrollBar()->sizeHint().width());
mCompleter->complete(cr); // popup it up!
if (mCompleter->completionCount()==0 && isShortcut){
QTextEdit::keyPressEvent(e);// Process the key if no match
}
mForceCompleterShowNextKeyEvent = false;
}
开发者ID:RedCraig,项目名称:retroshare,代码行数:56,代码来源:MimeTextEdit.cpp
示例19: cursorRect
//--------------------------------------------------------------------------------
void TextZone::centerCursor()
{
QRect cursor = cursorRect();
QRect viewport = this->viewport()->rect();
if (alwaysCenter || (cursor.bottom() >= viewport.bottom()) || (cursor.top() <= viewport.top())) {
QPoint offset = viewport.center() - cursor.center();
QScrollBar* scrollbar = verticalScrollBar();
scrollbar->setValue(scrollbar->value() - offset.y());
}
}
开发者ID:jwvdveen,项目名称:plume-creator-legacy,代码行数:11,代码来源:textzone.cpp
示例20: wordUnderTextCursor
void MLScriptEditor::showAutoComplete( QKeyEvent * /*e*/ )
{
QString w = wordUnderTextCursor();
QTextCursor tc = textCursor();
comp->setCompletionPrefix(w);
comp->popup()->setModel(comp->completionModel());
QRect rect = cursorRect();
rect.setWidth(comp->popup()->sizeHintForColumn(0) + comp->popup()->verticalScrollBar()->sizeHint().width());
comp->complete(rect);
}
开发者ID:quxiaofeng,项目名称:python-stl,代码行数:10,代码来源:additionalgui.cpp
注:本文中的cursorRect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论