本文整理汇总了C++中QMimeData::setText方法的典型用法代码示例。如果您正苦于以下问题:C++ QMimeData::setText方法的具体用法?C++ QMimeData::setText怎么用?C++ QMimeData::setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMimeData
的用法示例。
在下文中一共展示了QMimeData::setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMimeData
QMimeData * DraggableListWidget::mimeData ( const QList<QListWidgetItem *> items ) const
{
QString texts;
foreach (QListWidgetItem *item, items)
{
texts += item->text();
}
QMimeData *mimeData = new QMimeData();
mimeData->setText(texts);
return mimeData;
}
示例2: drag
void QLineEditPrivate::drag()
{
Q_Q(QLineEdit);
dndTimer.stop();
QMimeData *data = new QMimeData;
data->setText(control->selectedText());
QDrag *drag = new QDrag(q);
drag->setMimeData(data);
Qt::DropAction action = drag->start();
if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
control->removeSelection();
}
示例3: insertFromMimeData
/*!
* \author Anders Fernström
* \date 2006-01-23
*
* \brief If the mimedata that should be insertet contain text,
* create a new mimedata object that only contains text, otherwise
* text format is insertet also - don't want that for inputcells.
*/
void MyTextEdit::insertFromMimeData(const QMimeData *source)
{
if( source->hasText() )
{
QMimeData *newSource = new QMimeData();
newSource->setText( source->text() );
QTextBrowser::insertFromMimeData( newSource );
delete newSource;
}
else
QTextBrowser::insertFromMimeData( source );
}
示例4: mouseMoveEvent
void ExtendedTableWidget::mouseMoveEvent(QMouseEvent * event)
{
QTableWidgetItem *item = itemAt(event->pos());
if (item) {
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
mimeData->setText(item->text());
mimeData->setData(NUMBER_MIMETYPE, "");
drag->setMimeData(mimeData);
drag->start(Qt::CopyAction | Qt::MoveAction);
}
}
示例5: writePlainText
void Pasteboard::writePlainText(const String& text, SmartReplaceOption smartReplaceOption)
{
#ifndef QT_NO_CLIPBOARD
QMimeData* md = new QMimeData;
QString qtext = text;
qtext.replace(QChar(0xa0), QLatin1Char(' '));
md->setText(qtext);
if (smartReplaceOption == CanSmartReplace)
md->setData(QLatin1String("application/vnd.qtwebkit.smartpaste"), QByteArray());
QGuiApplication::clipboard()->setMimeData(md, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
#endif
}
示例6: copy
void WorksheetPrivate::copy()
{
QTextCursor cr = ws->textCursor();
if (cr.hasSelection())
{
QString text = cr.selectedText();
text.replace(QChar(QChar::ParagraphSeparator), "\n");
QMimeData *data = new QMimeData;
data->setText(text);
QApplication::clipboard()->setMimeData(data);
}
}
示例7: mouseMoveEvent
void ExperimentGraphBlockItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton)).length() < 5) //QApplication::startDragDistance())//not enough dragged?
return;
QDrag *drag = new QDrag(event->widget());
QMimeData *mime = new QMimeData;
mime->setText("Test123");
drag->setMimeData(mime);
drag->exec();
//setCursor(Qt::OpenHandCursor);
}
示例8: writeURL
void Pasteboard::writeURL(const KURL& url, const String&, Frame*)
{
ASSERT(!url.isEmpty());
#ifndef QT_NO_CLIPBOARD
QMimeData* md = new QMimeData;
QString urlString = url.string();
md->setText(urlString);
md->setUrls(QList<QUrl>() << url);
QGuiApplication::clipboard()->setMimeData(md, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
#endif
}
示例9: makeDrag
void ImageWIdget::makeDrag()
{
QDrag *dr = new QDrag(this);
// The data to be transferred by the drag and drop operation is contained in a QMimeData object
QMimeData *data = new QMimeData;
data->setText(myS.img.image_file);
// Assign ownership of the QMimeData object to the QDrag object.
dr->setMimeData(data);
// Start the drag and drop operation
dr->start();
}
示例10: mouseMoveEvent
// ************************************************************
void SymbolWidget::mouseMoveEvent(QMouseEvent*)
{
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
mimeData->setText("QucsComponent:"+theModel());
drag->setMimeData(mimeData);
drag->setPixmap( QPixmap(empty_xpm));
drag->setHotSpot(QPoint(drag->pixmap().width()/2,drag->pixmap().height()));
drag->exec();
}
示例11: mousePressEvent
void NowPlayingListWidget::mousePressEvent(QMouseEvent *event)
{
//after checking if we are in presence of a drag operation, we can then encapsulate
//the data to be sent and let start the drag operation
if (event->button() == Qt::LeftButton && itemAt(event->pos())) {
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData();
mimeData->setText(itemAt(event->pos())->text()); //who receives expects plain text data
drag->setMimeData(mimeData);
drag->exec();
}
}
示例12: performDrag
void BlockNavigationTreeWidget::performDrag()
{
QTreeWidgetItem *item = currentItem();
if(item)
{
QMimeData *mimeData = new QMimeData;
QString text = item->text(0);
mimeData->setText(item->text(0));
QDrag* drag = new QDrag(this);
drag->setMimeData(mimeData);
m_DropAction = drag->exec( Qt::CopyAction );
}
}
示例13: cursor
/**
* This is overridden in order to properly convert Icons back
* to their original text.
*/
QMimeData *PsiTextView::createMimeDataFromSelection() const
{
QTextDocument *doc = new QTextDocument();
QTextCursor cursor(doc);
cursor.insertFragment(textCursor().selection());
QString text = PsiRichText::convertToPlainText(doc);
delete doc;
QMimeData *data = new QMimeData;
data->setText(text);
data->setHtml(Qt::convertFromPlainText(text));
return data;
}
示例14: QMimeData
QMimeData *WindowModelBase::mimeData(const QModelIndexList &indexes) const
{
if (indexes.isEmpty ()) {
return nullptr;
}
QMimeData *data = new QMimeData ();
data->setHtml (selectionAsHtml ());
data->setText (selectionAsText (m_delimiter));
return data;
}
示例15: pushToClipboard
void ResultsJsInterface::pushToClipboard(const QString &mimeType, const QString &data, const QString &html)
{
QMimeData *mimeData = new QMimeData();
if (mimeType == "text/plain")
mimeData->setText(data);
if ( ! html.isEmpty())
mimeData->setHtml(html);
QClipboard *clipboard = QApplication::clipboard();
clipboard->setMimeData(mimeData, QClipboard::Clipboard);
}