本文整理汇总了C++中QDrag::mimeData方法的典型用法代码示例。如果您正苦于以下问题:C++ QDrag::mimeData方法的具体用法?C++ QDrag::mimeData怎么用?C++ QDrag::mimeData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDrag
的用法示例。
在下文中一共展示了QDrag::mimeData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotDragSnapshot
void KSnapshot::slotDragSnapshot()
{
QDrag *drag = new QDrag(this);
drag->setMimeData(new QMimeData);
drag->mimeData()->setImageData(snapshot);
drag->mimeData()->setData("application/x-kde-suggestedfilename", QFileInfo(file_path_).fileName().toUtf8());
drag->setPixmap(preview());
drag->start();
}
示例2: data_device_motion
void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixed_t y)
{
Q_UNUSED(time);
QDrag *drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag();
if (!drag && !m_dragOffer)
return;
m_dragPoint = QPoint(wl_fixed_to_int(x), wl_fixed_to_int(y));
QMimeData *dragData;
Qt::DropActions supportedActions;
if (drag) {
dragData = drag->mimeData();
supportedActions = drag->supportedActions();
} else {
dragData = m_dragOffer->mimeData();
supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
}
QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions);
if (drag) {
static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
} else {
if (response.isAccepted()) {
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
} else {
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, 0);
}
}
}
示例3: data_device_enter
void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface, wl_fixed_t x, wl_fixed_t y, wl_data_offer *id)
{
m_enterSerial = serial;
m_dragWindow = QWaylandWindow::fromWlSurface(surface)->window();
m_dragPoint = QPoint(wl_fixed_to_int(x), wl_fixed_to_int(y));
QDrag *drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag();
QMimeData *dragData;
Qt::DropActions supportedActions;
if (drag) {
dragData = drag->mimeData();
supportedActions = drag->supportedActions();
} else {
m_dragOffer.reset(static_cast<QWaylandDataOffer *>(wl_data_offer_get_user_data(id)));
if (m_dragOffer) {
dragData = m_dragOffer->mimeData();
supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
}
}
const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions);
if (drag) {
static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
} else {
if (response.isAccepted()) {
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
} else {
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, 0);
}
}
}
示例4: startDrag
void ImageButton::startDrag()
{
if ( !mPicture.data().isNull() ) {
QDrag *drag = new QDrag( this );
drag->setMimeData( new QMimeData() );
drag->mimeData()->setImageData( mPicture.data() );
drag->start();
}
}
示例5: mouseMoveEvent
void ImageWidget::mouseMoveEvent(QMouseEvent *event)
{
if ((event->buttons() & Qt::LeftButton) &&
(event->pos() - mDragStartPos).manhattanLength() > QApplication::startDragDistance()) {
if (mHasImage) {
QDrag *drag = new QDrag(this);
drag->setMimeData(new QMimeData());
drag->mimeData()->setImageData(mPicture.data());
drag->start();
}
}
}
示例6: mouseMoveEvent
void TabBar::mouseMoveEvent(QMouseEvent *AEvent)
{
if (AEvent->buttons()!=Qt::NoButton && FPressedIndex>=0 && count()>1 && (AEvent->pos()-FPressedPos).manhattanLength() > QApplication::startDragDistance())
{
TabBarItem *item = FItems.at(FPressedIndex);
QDrag *drag = new QDrag(this);
drag->setMimeData(new QMimeData);
drag->mimeData()->setData(MIME_TABITEM_INDEX,QByteArray::number(FPressedIndex));
drag->setPixmap(QPixmap::grabWidget(item));
drag->setHotSpot(FPressedPos - item->geometry().topLeft());
FDragCenterDistance = FPressedPos - item->geometry().center();
item->setDraging(true);
drag->exec(Qt::MoveAction);
item->setDraging(false);
}
}
示例7: data_device_drop
void QWaylandDataDevice::data_device_drop()
{
QDrag *drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag();
qDebug() << Q_FUNC_INFO << drag << m_dragOffer.data();
QMimeData *dragData = 0;
Qt::DropActions supportedActions;
if (drag) {
dragData = drag->mimeData();
supportedActions = drag->supportedActions();
} else if (m_dragOffer) {
dragData = m_dragOffer->mimeData();
supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
} else {
return;
}
QPlatformDropQtResponse response = QWindowSystemInterface::handleDrop(m_dragWindow, dragData, m_dragPoint, supportedActions);
if (drag) {
static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
}
}