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


C++ QDrag::mimeData方法代码示例

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

示例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);
        }
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:33,代码来源:qwaylanddatadevice.cpp

示例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);
        }
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:33,代码来源:qwaylanddatadevice.cpp

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

示例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();
        }
    }
}
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:13,代码来源:imagewidget.cpp

示例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);
    }
}
开发者ID:Rambler-ru,项目名称:Contacts,代码行数:18,代码来源:tabbar.cpp

示例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);
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:24,代码来源:qwaylanddatadevice.cpp


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