本文整理汇总了C++中QPlainTextEdit::parentWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QPlainTextEdit::parentWidget方法的具体用法?C++ QPlainTextEdit::parentWidget怎么用?C++ QPlainTextEdit::parentWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPlainTextEdit
的用法示例。
在下文中一共展示了QPlainTextEdit::parentWidget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: requestSetBlockSelection
void FakeVimProxy::requestSetBlockSelection(const QTextCursor &tc) {
QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(m_widget);
if (!ed)
return;
QPalette pal = ed->parentWidget() != NULL ? ed->parentWidget()->palette()
: QApplication::palette();
m_blockSelection.clear();
m_clearSelection.clear();
QTextCursor cur = tc;
QTextEdit::ExtraSelection selection;
selection.format.setBackground( pal.color(QPalette::Base) );
selection.format.setForeground( pal.color(QPalette::Text) );
selection.cursor = cur;
m_clearSelection.append(selection);
selection.format.setBackground( pal.color(QPalette::Highlight) );
selection.format.setForeground( pal.color(QPalette::HighlightedText) );
int from = cur.positionInBlock();
int to = cur.anchor() - cur.document()->findBlock(cur.anchor()).position();
const int min = qMin(cur.position(), cur.anchor());
const int max = qMax(cur.position(), cur.anchor());
for ( QTextBlock block = cur.document()->findBlock(min);
block.isValid() && block.position() < max; block = block.next() ) {
cur.setPosition( block.position() + qMin(from, block.length()) );
cur.setPosition( block.position() + qMin(to, block.length()), QTextCursor::KeepAnchor );
selection.cursor = cur;
m_blockSelection.append(selection);
}
disconnect( ed, &QPlainTextEdit::selectionChanged,
this, &FakeVimProxy::updateBlockSelection );
ed->setTextCursor(tc);
connect( ed, &QPlainTextEdit::selectionChanged,
this, &FakeVimProxy::updateBlockSelection );
QPalette pal2 = ed->palette();
pal2.setColor(QPalette::Highlight, Qt::transparent);
pal2.setColor(QPalette::HighlightedText, Qt::transparent);
ed->setPalette(pal2);
updateExtraSelections();
}
示例2: requestDisableBlockSelection
void FakeVimProxy::requestDisableBlockSelection() {
QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(m_widget);
if (!ed)
return;
QPalette pal = ed->parentWidget() != NULL ? ed->parentWidget()->palette()
: QApplication::palette();
m_blockSelection.clear();
m_clearSelection.clear();
ed->setPalette(pal);
disconnect( ed, &QPlainTextEdit::selectionChanged,
this, &FakeVimProxy::updateBlockSelection );
updateExtraSelections();
}