本文整理汇总了C++中QTextEdit::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::copy方法的具体用法?C++ QTextEdit::copy怎么用?C++ QTextEdit::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::copy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: editMenuActivated
void editMenuActivated(QAction *action)
{
QWidget* w = qApp->focusWidget();
QTextEdit* te = qobject_cast<QTextEdit*>(w);
QLineEdit* le = qobject_cast<QLineEdit*>(w);
if (action == selectAction) {
highlighting = this;
return;
}
highlighting = 0;
if (action == copyAction) {
if (te) {
if (te->hasEditFocus()) {
te->copy();
} else {
QTextCursor c = te->textCursor();
te->selectAll();
te->copy();
te->setTextCursor(c); // reset selection
}
} else if (le) {
if (le->hasEditFocus()) {
le->copy();
} else {
qApp->clipboard()->setText(le->text());
}
}
} else if (action == pasteAction) {
// assumes clipboard is not empty if 'Paste' is able to be
// activated, otherwise the line/textedit might be cleared
// without pasting anything back into it
if (te) {
if (!te->hasEditFocus())
te->clear();
te->paste();
if (!te->hasEditFocus()) {
te->moveCursor(QTextCursor::Start);
te->ensureCursorVisible();
}
} else if (le) {
if (!le->hasEditFocus())
le->clear();
le->paste();
if (!le->hasEditFocus())
le->home(false);
}
}
}
示例2: execute
/*!
* \class TextCursorCopyText
* \author Anders Fernström
* \date 2006-02-07
*
* \brief Command for copying text
*/
void TextCursorCopyText::execute()
{
Cell *cell = document()->getCursor()->currentCell();
if( cell )
{
if( typeid(InputCell) == typeid(*cell) )
{
InputCell *inputcell = dynamic_cast<InputCell*>(cell);
if( inputcell->textEditOutput()->hasFocus() &&
inputcell->isEvaluated() )
{
inputcell->textEditOutput()->copy();
}
else
inputcell->textEdit()->copy();
}
else if( typeid(GraphCell) == typeid(*cell) )
{
GraphCell *graphcell = dynamic_cast<GraphCell*>(cell);
if( graphcell->textEditOutput()->hasFocus() &&
graphcell->isEvaluated() )
{
graphcell->textEditOutput()->copy();
}
else
graphcell->textEdit()->copy();
}
else if( typeid(LatexCell) == typeid(*cell) )
{
LatexCell *latexcell = dynamic_cast<LatexCell*>(cell);
if( latexcell->textEditOutput()->hasFocus() &&
latexcell->isEvaluated() )
{
latexcell->textEditOutput()->copy();
}
else
latexcell->textEdit()->copy();
}
else
{
QTextEdit *editor = cell->textEdit();
if( editor )
{
editor->copy();
}
}
}
}
示例3: copy
void CBaseEditWindow::copy( void )
{
QTextEdit* doc = activeDocument();
if( doc != NULL ) { doc->copy(); }
}
示例4: textEditCopy
// コピー
void MainWindow::textEditCopy() {
QTextEdit* textEdit = getCurrentTextEdit();
if (textEdit == NULL) return;
textEdit->copy();
}