本文整理汇总了C++中QClipboard::setMimeData方法的典型用法代码示例。如果您正苦于以下问题:C++ QClipboard::setMimeData方法的具体用法?C++ QClipboard::setMimeData怎么用?C++ QClipboard::setMimeData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QClipboard
的用法示例。
在下文中一共展示了QClipboard::setMimeData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_editorCommandPaste_triggered
void CWizDocumentWebViewPage::on_editorCommandPaste_triggered()
{
QClipboard* clip = QApplication::clipboard();
Q_ASSERT(clip);
const QMimeData* mime = clip->mimeData();
// QStringList formats = mime->formats();
// for(int i = 0; i < formats.size(); ++ i) {
// qDebug() << "Mime Format: " << formats.at(i) << " Mime data: " << mime->data(formats.at(i));
// }
if (mime->hasHtml())
{
QString strHtml = mime->html();
QRegExp regHead("</?head[^>]*>", Qt::CaseInsensitive);
if (strHtml.contains(regHead))
{
// convert mass html to rtf, then convert rft to html
QTextDocument textParase;
textParase.setHtml(strHtml);
strHtml = textParase.toHtml();
QRegExp regBodyContant("<body[^>]*>[\\s\\S]*</body>");
int index = regBodyContant.indexIn(strHtml);
if (index > -1)
{
QString strBody = regBodyContant.cap(0);
if (strBody.isEmpty())
return;
QRegExp regBody = QRegExp("</?body[^>]*>", Qt::CaseInsensitive);
strBody.replace(regBody, "");
strHtml = strBody;
QMimeData* data = new QMimeData();
data->setHtml(strHtml);
clip->setMimeData(data);
return;
}
}
}
if (!clip->image().isNull()) {
// save clipboard image to $TMPDIR
QString strTempPath = Utils::PathResolve::tempPath();
CString strFileName = strTempPath + WizIntToStr(GetTickCount()) + ".png";
if (!clip->image().save(strFileName)) {
TOLOG("ERROR: Can't save clipboard image to file");
return;
}
QMimeData* data = new QMimeData();
QString strHtml = getImageHtmlLabelByFile(strFileName);
data->setHtml(strHtml);
clip->setMimeData(data);
}
}
示例2: pushImageToClipboard
void ResultsJsInterface::pushImageToClipboard(const QByteArray &base64, const QString &html)
{
QMimeData *mimeData = new QMimeData();
QByteArray byteArray = QByteArray::fromBase64(base64);
QImage pm;
if(pm.loadFromData(byteArray))
{
#ifdef __WIN32__ //needed because jpegs/clipboard doesn't support transparency in windows
QImage image2(pm.size(), QImage::Format_ARGB32);
image2.fill(Qt::white);
QPainter painter(&image2);
painter.drawImage(0, 0, pm);
mimeData->setImageData(image2);
#else
mimeData->setImageData(pm);
#endif
}
if ( ! html.isEmpty())
mimeData->setHtml(html);
if (mimeData->hasImage() || mimeData->hasHtml())
{
QClipboard *clipboard = QApplication::clipboard();
clipboard->setMimeData(mimeData, QClipboard::Clipboard);
}
}
示例3: onButtonClicked
void ClipboardItem::onButtonClicked()
{
QClipboard *sysClipboard = QApplication::clipboard();
QMimeData *clipMime = new QMimeData;
if(mimeType != "screen") {
if (mimeType == "html") {
clipMime->setHtml(data);
clipMime->setText(dataPlain);
} else if (mimeType == "plain") {
clipMime->setText(data);
} else {
delete clipMime;
return;
}
sysClipboard->setMimeData(clipMime);
} else {
QString groupAddress;
QSettings *settings = new QSettings;
int pinMod = settings->value("pin").toInt() % 256;
delete settings;
groupAddress = "239.255.0." + QString::number(pinMod);
vlc = new QProcess;
vlc->start("vlc udp://" + data + "@" + groupAddress + ":12345");
}
}
示例4: data
void
NodeGraph::copySelectedNodes()
{
if ( _imp->_selection.empty() ) {
Dialogs::warningDialog( tr("Copy").toStdString(), tr("You must select at least a node to copy first.").toStdString() );
return;
}
SERIALIZATION_NAMESPACE::NodeClipBoard cb;
_imp->copyNodesInternal(_imp->_selection, &cb.nodes);
std::ostringstream ss;
try {
SERIALIZATION_NAMESPACE::write(ss, cb, NATRON_CLIPBOARD_HEADER);
} catch (...) {
qDebug() << "Failed to copy selection to system clipboard";
}
QMimeData* mimedata = new QMimeData;
QByteArray data( ss.str().c_str() );
mimedata->setData(QLatin1String("text/plain"), data);
QClipboard* clipboard = QApplication::clipboard();
//ownership is transferred to the clipboard
clipboard->setMimeData(mimedata);
}
示例5: on_editorCommandPaste_triggered
void CWizDocumentWebViewPage::on_editorCommandPaste_triggered()
{
QClipboard* clip = QApplication::clipboard();
Q_ASSERT(clip);
//const QMimeData* mime = clip->mimeData();
//qDebug() << mime->formats();
//qDebug() << mime->data("text/html");
//qDebug() << mime->hasImage();
if (!clip->image().isNull()) {
// save clipboard image to $TMPDIR
QString strTempPath = Utils::PathResolve::tempPath();
CString strFileName = strTempPath + WizIntToStr(GetTickCount()) + ".png";
if (!clip->image().save(strFileName)) {
TOLOG("ERROR: Can't save clipboard image to file");
return;
}
QMimeData* data = new QMimeData();
QString strHtml = getImageHtmlLabelByFile(strFileName);
data->setHtml(strHtml);
clip->setMimeData(data);
}
}
示例6: copySelection
void FxSelection::copySelection() {
QClipboard *clipboard = QApplication::clipboard();
FxsData *fxsData = new FxsData();
fxsData->setFxs(m_selectedFxs, m_selectedLinks, m_selectedColIndexes,
m_xshHandle->getXsheet());
clipboard->setMimeData(fxsData);
}
示例7: copyIncidences
bool DndFactory::copyIncidences( const Incidence::List &incidences )
{
QClipboard *clipboard = QApplication::clipboard();
Q_ASSERT( clipboard );
MemoryCalendar::Ptr calendar( new MemoryCalendar( d->mCalendar->timeSpec() ) );
Incidence::List::ConstIterator it;
for ( it = incidences.constBegin(); it != incidences.constEnd(); ++it ) {
if ( *it ) {
calendar->addIncidence( Incidence::Ptr( ( *it )->clone() ) );
}
}
QMimeData *mimeData = new QMimeData;
ICalDrag::populateMimeData( mimeData, calendar );
VCalDrag::populateMimeData( mimeData, calendar );
if ( calendar->incidences().isEmpty() ) {
return false;
} else {
clipboard->setMimeData( mimeData );
return true;
}
}
示例8: copyCellsKeyframes
void TCellKeyframeSelection::copyCellsKeyframes() {
TCellKeyframeData *data = new TCellKeyframeData();
// Copy cells
int r0, c0, r1, c1;
m_cellSelection->getSelectedCells(r0, c0, r1, c1);
if (!isEmpty()) {
int colCount = c1 - c0 + 1;
int rowCount = r1 - r0 + 1;
if (colCount <= 0 || rowCount <= 0) return;
TXsheet *xsh = m_xsheetHandle->getXsheet();
TCellData *cellData = new TCellData();
cellData->setCells(xsh, r0, c0, r1, c1);
data->setCellData(cellData);
}
// Copy keyframes
if (!isEmpty()) {
QClipboard *clipboard = QApplication::clipboard();
TXsheet *xsh = m_xsheetHandle->getXsheet();
TKeyframeData *keyframeData = new TKeyframeData();
TKeyframeData::Position startPos(r0, c0);
keyframeData->setKeyframes(m_keyframeSelection->getSelection(), xsh,
startPos);
data->setKeyframeData(keyframeData);
}
// Set the cliboard
QClipboard *clipboard = QApplication::clipboard();
clipboard->setMimeData(data, QClipboard::Clipboard);
}
示例9: ClaimSelection
// Claim the selection.
void ScintillaQt::ClaimSelection()
{
bool isSel = !sel.Empty();
if (isSel)
{
QClipboard *cb = QApplication::clipboard();
// If we support X11 style selection then make it available now.
if (cb->supportsSelection())
{
SelectionText text;
CopySelectionRange(&text);
if (text.s)
cb->setMimeData(mimeSelection(text), QClipboard::Selection);
}
primarySelection = true;
}
else
primarySelection = false;
emit qsb->QSCN_SELCHANGED(isSel);
}
示例10: matlabCopyScript
void matlabCopyScript(const QList<QList<double> >& data) {
QString matlab=toMatlabScript(data, false);
QClipboard *clipboard = QApplication::clipboard();
QMimeData* mime=new QMimeData();
mime->setText(matlab);
clipboard->setMimeData(mime);
}
示例11: copy
void LineBuilderState::copy()
{
if (log)
Logger::getLogger()->infoLog() << "LineBuilderState::copy()\n";
QClipboard *buffer = QApplication::clipboard();
RoadElementMimeData* data = new RoadElementMimeData(lineBroken);
buffer->setMimeData(data);
}
示例12: copySelection
// copy to clipboard
void KFindTreeView::copySelection()
{
QMimeData * mime = m_model->mimeData( m_proxyModel->mapSelectionToSource( selectionModel()->selection() ).indexes() );
if (mime)
{
QClipboard * cb = qApp->clipboard();
cb->setMimeData( mime );
}
}
示例13: convertClipboardHtmlImages
void WebView::convertClipboardHtmlImages(QClipboard::Mode mode)
{
QClipboard *cb = QApplication::clipboard();
QString html = TextUtil::img2title(selectedHtml());
QMimeData *data = new QMimeData;
data->setHtml(html);
data->setText(TextUtil::rich2plain(html, false));
cb->setMimeData(data, mode);
}
示例14: onCopyAsked
void MOTableView::onCopyAsked()
{
QModelIndexList indexList = this->selectedIndexes();
if(model())
{
QMimeData* mimeData = model()->mimeData(indexList);
QClipboard *clipboard = QApplication::clipboard();
clipboard->setMimeData(mimeData);
}
}
示例15: activated
void StdCmdCopy::activated(int iMsg)
{
bool done = getGuiApplication()->sendMsgToActiveView("Copy");
if (!done) {
WaitCursor wc;
QMimeData * mimeData = getMainWindow()->createMimeDataFromSelection();
QClipboard* cb = QApplication::clipboard();
cb->setMimeData(mimeData);
}
}