本文整理汇总了C++中QDrag::target方法的典型用法代码示例。如果您正苦于以下问题:C++ QDrag::target方法的具体用法?C++ QDrag::target怎么用?C++ QDrag::target使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDrag
的用法示例。
在下文中一共展示了QDrag::target方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseMoveEvent
void TabBar::mouseMoveEvent(QMouseEvent *event)
{
if(!(event->buttons() & Qt::LeftButton))
return;
if((event->pos() - drag_pos).manhattanLength() < DRAG_OFFSET)
return;
fn_begin;
event->accept();
QDrag *drag = new QDrag(this);
/*DEBUG*/
drag->setObjectName("drag");
connect(drag, SIGNAL(destroyed()), twutil, SLOT(dumpDestroyed()));
QMimeData *mimedata = new QMimeData();
QWidget *widget = currentWidget();
mimedata->setData("action", "window_drag");
drag->setMimeData(mimedata);
QPixmap pixmap = QPixmap::grabWidget(widget).scaledToWidth(
PIXMAP_MAXWIDTH(widget->width()), Qt::SmoothTransformation);
DragPixmap *dragpixmap = new DragPixmap(pixmap, PIXMAP_OPACITY, widget);
connect(drag, SIGNAL(destroyed()), dragpixmap, SLOT(deleteLater()));
dragpixmap->setObjectName("dragpixmap");
connect(dragpixmap, SIGNAL(destroyed()), twutil, SLOT(dumpDestroyed()));
dragpixmap->show();
drag->exec();
emit widgetDnD(currentWidget(), drag->target());
QTabBar::mouseMoveEvent(event);
fn_end;
}
示例2: mouseMoveEvent
void QuickLaunchButton::mouseMoveEvent(QMouseEvent *e)
{
if (!(e->buttons() & Qt::LeftButton))
{
return;
}
if ((e->pos() - mDragStart).manhattanLength() < QApplication::startDragDistance())
{
return;
}
if (e->modifiers() != Qt::ControlModifier)
{
return;
}
QDrag *drag = new QDrag(this);
ButtonMimeData *mimeData = new ButtonMimeData();
mimeData->setButton(this);
drag->setMimeData(mimeData);
drag->exec(Qt::MoveAction);
// Icon was droped outside the panel, remove button
if (!drag->target())
{
selfRemove();
}
}
示例3: mousePressEvent
void ColumnDropCSVView::mousePressEvent(QMouseEvent *press)
{
QModelIndex atClick = indexAt(press->pos());
if (!atClick.isValid() || atClick.row())
return;
QRect indexRect = visualRect(atClick);
QPixmap pix(indexRect.width(), indexRect.height());
pix.fill(QColor(0,0,0,0));
render(&pix, QPoint(0, 0),QRegion(indexRect));
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
mimeData->setData(subsurface_mimedata, atClick.data().toByteArray());
mimeData->setData(subsurface_index, QString::number(atClick.column()).toUtf8());
drag->setPixmap(pix);
drag->setMimeData(mimeData);
if (drag->exec() != Qt::IgnoreAction){
QObject *target = drag->target();
if (target->objectName() == "qt_scrollarea_viewport")
target = target->parent();
if (target != drag->source())
model()->setData(atClick, QString());
}
}
示例4: dragObjectDestroyed
void PanelBrowserMenu::dragObjectDestroyed(QObject* o)
{
QDrag* drag = dynamic_cast<QDrag*>(o);
if (drag && drag->target() != this)
{
close();
}
}
示例5: drag
void QLineEditPrivate::drag()
{
Q_Q(QLineEdit);
dndTimer.stop();
QMimeData *data = new QMimeData;
data->setText(control->selectedText());
QDrag *drag = new QDrag(q);
drag->setMimeData(data);
Qt::DropAction action = drag->start();
if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
control->removeSelection();
}
示例6: StartDrag
// Start a drag.
void QsciScintillaQt::StartDrag()
{
inDragDrop = ddDragging;
QDrag *qdrag = new QDrag(qsb);
qdrag->setMimeData(mimeSelection(drag));
# if QT_VERSION >= 0x040300
Qt::DropAction action = qdrag->exec(Qt::MoveAction | Qt::CopyAction, Qt::MoveAction);
# else
Qt::DropAction action = qdrag->start(Qt::MoveAction);
# endif
// Remove the dragged text if it was a move to another widget or
// application.
if (action == Qt::MoveAction && qdrag->target() != qsb->viewport())
ClearSelection();
SetDragPosition(QSCI_SCI_NAMESPACE(SelectionPosition)());
inDragDrop = ddNone;
}
示例7: timerEvent
void PersistentState::timerEvent(QTimerEvent *e) {
if (e->timerId() == _dragStartTimer.timerId()) {
_dragStartTimer.stop();
_mousePressed = false;
QMimeData *data = createMimeDataFromSelection();
QDrag *drag = new QDrag(editor());
drag->setMimeData(data);
Qt::DropActions actions = Qt::CopyAction;
if (!editor()->isReadOnly())
actions |= Qt::MoveAction;
Qt::DropAction action = drag->start(actions);
if (action == Qt::MoveAction && drag->target() != editor())
_persistentCursor.removeSelectedText();
}
}
示例8: mouseMoveEvent
void ToolBar::mouseMoveEvent(QMouseEvent *event)
{
QToolBar::mouseMoveEvent(event);
QAction *action = this->actionAt(m_dragPos);
if (event->buttons() & Qt::LeftButton && action && isEdited()) {
qint32 distance = (event->pos() - m_dragPos).manhattanLength();
if (distance > QApplication::startDragDistance() ) {
QDrag *drag = new QDrag(this);
MimeDataObject *mimeData = new MimeDataObject();
mimeData->setObject(action);
drag->setMimeData(mimeData);
if (drag->exec(Qt::MoveAction) == Qt::MoveAction)
if (drag->target() != this || action->isSeparator())
this->removeAction(action);
return;
}
}
}
示例9: StartDrag
// Start a drag.
void ScintillaQt::StartDrag()
{
inDragDrop = ddDragging;
QDrag *qdrag = new QDrag(qsb);
qdrag->setMimeData(mimeSelection(drag));
# if QT_VERSION >= 0x040300
// The default action is to copy so that the cursor is correct when over
// another widget or application (when we have no control over it). We
// make sure it is correct over ourself in the event handlers.
Qt::DropAction action = qdrag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction);
# else
Qt::DropAction action = qdrag->start(Qt::MoveAction);
# endif
// Remove the dragged text if it was a move to another widget or
// application.
if (action == Qt::MoveAction && qdrag->target() != qsb->viewport())
ClearSelection();
SetDragPosition(SelectionPosition());
inDragDrop = ddNone;
}
示例10: startDrag
void MouseNavigator::startDrag()
{
// reset states
mLMBPressed = false;
mInLMBDoubleClick = false;
mDragStartPossible = false;
// create data
QMimeData* dragData = mView->selectionAsMimeData();
if( ! dragData )
return;
QDrag* drag = new QDrag( mView );
drag->setMimeData( dragData );
Qt::DropActions request = (mView->isReadOnly()||mView->isOverwriteMode()) ? Qt::CopyAction : Qt::CopyAction|Qt::MoveAction;
Qt::DropAction dropAction = drag->exec( request );
if( dropAction == Qt::MoveAction )
{
AbstractByteArrayView* targetByteArrayView = qobject_cast<AbstractByteArrayView*>( drag->target() );
// Not inside this widget itself?
if( ! targetByteArrayView
|| targetByteArrayView->byteArrayModel() != mView->byteArrayModel() )
mView->removeSelectedData();
}
}