当前位置: 首页>>代码示例>>C++>>正文


C++ QClipboard::setMimeData方法代码示例

本文整理汇总了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);
    }
}
开发者ID:guanxiaochao,项目名称:WizQTClient,代码行数:57,代码来源:wizDocumentWebView.cpp

示例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);
	}
}
开发者ID:akashrajkn,项目名称:jasp-desktop,代码行数:31,代码来源:resultsjsinterface.cpp

示例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");
    }
}
开发者ID:RiteshAgrawal,项目名称:kollaborate,代码行数:28,代码来源:clipboarditem.cpp

示例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);
}
开发者ID:kcotugno,项目名称:Natron,代码行数:28,代码来源:NodeGraph40.cpp

示例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);
    }
}
开发者ID:edagarli,项目名称:WizQTClient,代码行数:25,代码来源:wizDocumentWebView.cpp

示例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);
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:7,代码来源:fxselection.cpp

示例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;
  }
}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:25,代码来源:dndfactory.cpp

示例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);
}
开发者ID:opentoonz,项目名称:opentoonz,代码行数:28,代码来源:cellkeyframeselection.cpp

示例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);
}
开发者ID:Open-Turing-Project,项目名称:turing-editor-qt,代码行数:27,代码来源:ScintillaQt.cpp

示例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);
}
开发者ID:jkriege2,项目名称:QuickFit3,代码行数:8,代码来源:matlabtools.cpp

示例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);
}
开发者ID:AlexeyKulbitsky,项目名称:Constructor,代码行数:8,代码来源:linebuilderstate.cpp

示例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 );
    }
}
开发者ID:KDE,项目名称:kde-baseapps,代码行数:10,代码来源:kfindtreeview.cpp

示例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);
}
开发者ID:akatov,项目名称:psi,代码行数:9,代码来源:webview.cpp

示例14: onCopyAsked

void MOTableView::onCopyAsked()
{
    QModelIndexList indexList = this->selectedIndexes();
    if(model())
    {
        QMimeData* mimeData = model()->mimeData(indexList);
        QClipboard *clipboard = QApplication::clipboard();
        clipboard->setMimeData(mimeData);
    }
}
开发者ID:OpenModelica,项目名称:OMOptim,代码行数:10,代码来源:MOTableView.cpp

示例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);
    }
}
开发者ID:pedrocalderon,项目名称:FreeCAD_sf_master,代码行数:10,代码来源:CommandDoc.cpp


注:本文中的QClipboard::setMimeData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。