本文整理汇总了C++中QTextCursor::hasComplexSelection方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextCursor::hasComplexSelection方法的具体用法?C++ QTextCursor::hasComplexSelection怎么用?C++ QTextCursor::hasComplexSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextCursor
的用法示例。
在下文中一共展示了QTextCursor::hasComplexSelection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateCustomTextColor
/*!
This slot applies custom text color for user - entered text
It does not affect the text originally inserted into editor
*/
void NmEditorTextEdit::updateCustomTextColor()
{
NM_FUNCTION;
if (mCustomTextColor.first) {
QTextCursor tcursor = textCursor();
QTextCharFormat fmt;
int pos = tcursor.position();
if (pos > 0) {
// If there isn't any user-made selection - apply custom color
if (!tcursor.hasSelection() && !tcursor.hasComplexSelection()) {
// Select last added char and set its color to custom
if (tcursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, 1)
&& tcursor.hasSelection()) {
fmt = tcursor.charFormat();
fmt.setForeground(mCustomTextColor.second);
tcursor.mergeCharFormat(fmt);
}
}
}
else {
fmt = tcursor.charFormat();
fmt.setForeground(mCustomTextColor.second);
tcursor.mergeCharFormat(fmt);
setTextCursor(tcursor);
}
}
}
示例2: mergeCells
/*!
\overload
\since 4.1
Merges the cells selected by the provided \a cursor.
\sa splitCell()
*/
void QTextTable::mergeCells(const QTextCursor &cursor)
{
if (!cursor.hasComplexSelection())
return;
int firstRow, numRows, firstColumn, numColumns;
cursor.selectedTableCells(&firstRow, &numRows, &firstColumn, &numColumns);
mergeCells(firstRow, firstColumn, numRows, numColumns);
}
示例3: sqlButtonPressed
void SQLDialog::sqlButtonPressed()
{
QTextCursor cursor = m_textEdit->textCursor();
if (cursor.hasComplexSelection())
{
// TODO: Error? Iterate over selections
//ScrollMessageBox::information(this, "Simple Selection", cursor.selectedText());
ScrollMessageBox::information(this, "Complex Selection", "??");
}
else if (cursor.hasSelection())
{
executeSql(cursor.selectedText());
}
else
{
executeSql(cursor.block().text());
}
}