本文整理汇总了C++中QDrag::deleteLater方法的典型用法代码示例。如果您正苦于以下问题:C++ QDrag::deleteLater方法的具体用法?C++ QDrag::deleteLater怎么用?C++ QDrag::deleteLater使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDrag
的用法示例。
在下文中一共展示了QDrag::deleteLater方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseMoveEvent
void LXQtTaskButton::mouseMoveEvent(QMouseEvent* event)
{
if (!(event->buttons() & Qt::LeftButton))
return;
if ((event->pos() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance())
return;
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData());
QIcon ico = icon();
QPixmap img = ico.pixmap(ico.actualSize({32, 32}));
drag->setPixmap(img);
switch (parentTaskBar()->panel()->position())
{
case ILXQtPanel::PositionLeft:
case ILXQtPanel::PositionTop:
drag->setHotSpot({0, 0});
break;
case ILXQtPanel::PositionRight:
case ILXQtPanel::PositionBottom:
drag->setHotSpot(img.rect().bottomRight());
break;
}
sDraggging = true;
drag->exec();
// if button is dropped out of panel (e.g. on desktop)
// it is not deleted automatically by Qt
drag->deleteLater();
sDraggging = false;
QAbstractButton::mouseMoveEvent(event);
}
示例2: PerformDrag
void LocalVideoWidget::PerformDrag() {
// TODO: 暂时将media_id作为uri
MimeTextBuilder text_builder(media_id_);
text_builder.AddVirtualURI(media_id_);
QMimeData *mime_data = new QMimeData();
mime_data->setText(text_builder.GetText());
QDrag *drag = new QDrag(this);
drag->setMimeData(mime_data);
QPixmap p(image_url_);
drag->setPixmap(p);
drag->setHotSpot(QPoint(p.size().width() / 2, p.size().height() / 2));
// 在windows上exec会阻塞event loop
drag->exec();
// 在windows上需要删除drag
drag->deleteLater();
}
示例3: PerformDrag
void VirtualTerminalWidget::PerformDrag() {
MimeTextBuilder text_builder(uri_);
text_builder.AddVirtualURI(virtual_uri_);
QMimeData *mime_data = new QMimeData();
mime_data->setText(text_builder.GetText());
QDrag *drag = new QDrag(this);
drag->setMimeData(mime_data);
QPixmap p(image_url_);
drag->setPixmap(p);
drag->setHotSpot(QPoint(p.size().width() / 2, p.size().height() / 2));
// 在windows上event loop会被阻塞
drag->exec();
// 在windwos需要删除drag
drag->deleteLater();
}
示例4: startDrag
Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedActions)
{
Q_Q(QQuickDragAttached);
QDrag *drag = new QDrag(q);
QMimeData *mimeData = new QMimeData();
Q_FOREACH (const QString &key, externalMimeData.keys()) {
mimeData->setData(key, externalMimeData[key].toString().toUtf8());
}
drag->setMimeData(mimeData);
// TODO: how to handle drag image?
// drag->setPixmap(iconPixmap);
emit q->dragStarted();
Qt::DropAction dropAction = drag->exec(supportedActions);
if (!QGuiApplicationPrivate::platformIntegration()->drag()->ownsDragObject())
drag->deleteLater();
deliverLeaveEvent();
if (target) {
target = 0;
emit q->targetChanged();
}
emit q->dragFinished(dropAction);
active = false;
emit q->activeChanged();
return dropAction;
}