本文整理汇总了C++中QTextDocument::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextDocument::isEmpty方法的具体用法?C++ QTextDocument::isEmpty怎么用?C++ QTextDocument::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextDocument
的用法示例。
在下文中一共展示了QTextDocument::isEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isEmpty
bool QTextDocumentProto::isEmpty() const
{
QTextDocument *item = qscriptvalue_cast<QTextDocument*>(thisObject());
if (item)
return item->isEmpty();
return false;
}
示例2: insertFromMimeData
void MessageEditor::insertFromMimeData(const QMimeData *ASource)
{
QTextDocument doc;
emit insertDataRequest(ASource,&doc);
if (!doc.isEmpty())
{
QTextCursor cursor(&doc);
cursor.select(QTextCursor::Document);
if (acceptRichText())
textCursor().insertFragment(cursor.selection());
else
textCursor().insertText(cursor.selection().toPlainText());
}
ensureCursorVisible();
setFocus();
}
示例3: textCursor
QMenu *
SimpleRichTextEdit::createContextMenu(const QPoint &mouseGlobalPos)
{
Qt::TextInteractionFlags interactionFlags = this->textInteractionFlags();
QTextDocument *document = this->document();
QTextCursor cursor = textCursor();
const bool showTextSelectionActions = (Qt::TextEditable | Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse) & interactionFlags;
QMenu *menu = new QMenu(this);
if(interactionFlags & Qt::TextEditable) {
m_actions[Undo]->setEnabled(document->isUndoAvailable());
menu->addAction(m_actions[Undo]);
m_actions[Redo]->setEnabled(document->isRedoAvailable());
menu->addAction(m_actions[Redo]);
menu->addSeparator();
m_actions[Cut]->setEnabled(cursor.hasSelection());
menu->addAction(m_actions[Cut]);
}
if(showTextSelectionActions) {
m_actions[Copy]->setEnabled(cursor.hasSelection());
menu->addAction(m_actions[Copy]);
}
if(interactionFlags & Qt::TextEditable) {
#if !defined(QT_NO_CLIPBOARD)
m_actions[Paste]->setEnabled(canPaste());
menu->addAction(m_actions[Paste]);
#endif
m_actions[Delete]->setEnabled(cursor.hasSelection());
menu->addAction(m_actions[Delete]);
m_actions[Clear]->setEnabled(!document->isEmpty());
menu->addAction(m_actions[Clear]);
if(m_insertUnicodeControlCharMenu && interactionFlags & Qt::TextEditable) {
menu->addSeparator();
menu->addMenu(m_insertUnicodeControlCharMenu);
}
}
if(showTextSelectionActions) {
menu->addSeparator();
m_actions[SelectAll]->setEnabled(!document->isEmpty());
menu->addAction(m_actions[SelectAll]);
}
if(interactionFlags & Qt::TextEditable) {
menu->addSeparator();
m_actions[ToggleBold]->setCheckable(true);
m_actions[ToggleBold]->setChecked(fontBold());
menu->addAction(m_actions[ToggleBold]);
m_actions[ToggleItalic]->setCheckable(true);
m_actions[ToggleItalic]->setChecked(fontItalic());
menu->addAction(m_actions[ToggleItalic]);
m_actions[ToggleUnderline]->setCheckable(true);
m_actions[ToggleUnderline]->setChecked(fontUnderline());
menu->addAction(m_actions[ToggleUnderline]);
m_actions[ToggleStrikeOut]->setCheckable(true);
m_actions[ToggleStrikeOut]->setChecked(fontStrikeOut());
menu->addAction(m_actions[ToggleStrikeOut]);
menu->addAction(m_actions[ChangeTextColor]);
menu->addSeparator();
m_actions[CheckSpelling]->setEnabled(!document->isEmpty());
menu->addAction(m_actions[CheckSpelling]);
m_actions[ToggleAutoSpellChecking]->setChecked(checkSpellingEnabled());
menu->addAction(m_actions[ToggleAutoSpellChecking]);
if(checkSpellingEnabled()) {
setupWordUnderPositionCursor(mouseGlobalPos);
QString selectedWord = m_selectedWordCursor.selectedText();
if(!selectedWord.isEmpty() && highlighter() && highlighter()->isWordMisspelled(selectedWord)) {
QMenu *suggestionsMenu = menu->addMenu(i18n("Suggestions"));
suggestionsMenu->addAction(i18n("Ignore"), this, SLOT(addToIgnoreList()));
suggestionsMenu->addAction(i18n("Add to Dictionary"), this, SLOT(addToDictionary()));
suggestionsMenu->addSeparator();
QStringList suggestions = highlighter()->suggestionsForWord(m_selectedWordCursor.selectedText());
if(suggestions.empty())
suggestionsMenu->addAction(i18n("No suggestions"))->setEnabled(false);
else {
for(QStringList::ConstIterator it = suggestions.begin(), end = suggestions.end(); it != end; ++it)
suggestionsMenu->addAction(*it, this, SLOT(replaceWithSuggestion()));
}
}
}
//.........这里部分代码省略.........