本文整理汇总了C++中QMimeData::hasImage方法的典型用法代码示例。如果您正苦于以下问题:C++ QMimeData::hasImage方法的具体用法?C++ QMimeData::hasImage怎么用?C++ QMimeData::hasImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMimeData
的用法示例。
在下文中一共展示了QMimeData::hasImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: startDrag
void DragClientQt::startDrag(DragImageRef dragImage, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool)
{
#ifndef QT_NO_DRAGANDDROP
QMimeData* clipboardData = clipboard->pasteboard().clipboardData();
clipboard->pasteboard().invalidateWritableData();
PlatformPageClient pageClient = m_chromeClient->platformPageClient();
QObject* view = pageClient ? pageClient->ownerWidget() : 0;
if (view) {
QDrag* drag = new QDrag(view);
if (dragImage) {
drag->setPixmap(*dragImage);
drag->setHotSpot(IntPoint(eventPos - dragImageOrigin));
} else if (clipboardData && clipboardData->hasImage())
drag->setPixmap(qvariant_cast<QPixmap>(clipboardData->imageData()));
DragOperation dragOperationMask = clipboard->sourceOperation();
drag->setMimeData(clipboardData);
Qt::DropAction actualDropAction = drag->exec(dragOperationsToDropActions(dragOperationMask));
// Send dragEnd event
PlatformMouseEvent me(m_chromeClient->screenToRootView(QCursor::pos()), QCursor::pos(), LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, 0);
frame->eventHandler()->dragSourceEndedAt(me, dropActionToDragOperation(actualDropAction));
}
frame->page()->dragController()->dragEnded();
#endif
}
示例3: hasImage
void tst_QMimeData::hasImage() const
{
QMimeData mimeData;
// initial state
QVERIFY(mimeData.hasImage() == false);
// add text, verify false
mimeData.setData("text/plain", "pirates");
QVERIFY(mimeData.hasImage() == false);
// add image
mimeData.setImageData(QImage());
QVERIFY(mimeData.hasImage());
// clear, verify
mimeData.clear();
QVERIFY(mimeData.hasImage() == false);
}
示例4:
QDebug operator<<(QDebug d, const QMimeData &m)
{
QDebug nospace = d.nospace();
const QStringList formats = m.formats();
nospace << "QMimeData: " << formats.join(QStringLiteral(", ")) << '\n'
<< " Text=" << m.hasText() << " HTML=" << m.hasHtml()
<< " Color=" << m.hasColor() << " Image=" << m.hasImage()
<< " URLs=" << m.hasUrls() << '\n';
if (m.hasText())
nospace << " Text: '" << m.text() << "'\n";
if (m.hasHtml())
nospace << " HTML: '" << m.html() << "'\n";
if (m.hasColor())
nospace << " Color: " << qvariant_cast<QColor>(m.colorData()) << '\n';
if (m.hasImage())
nospace << " Image: " << qvariant_cast<QImage>(m.imageData()).size() << '\n';
if (m.hasUrls())
nospace << " URLs: " << m.urls() << '\n';
return d;
}
示例5: imageData
void tst_QMimeData::imageData() const
{
QMimeData mimeData;
// initial state
QCOMPARE(mimeData.imageData(), QVariant());
// set, test
mimeData.setImageData(QImage());
QVERIFY(mimeData.hasImage());
QCOMPARE(mimeData.imageData(), QVariant(QImage()));
// clear, verify
mimeData.clear();
QCOMPARE(mimeData.imageData(), QVariant());
}