本文整理汇总了C++中QDrag::setDragCursor方法的典型用法代码示例。如果您正苦于以下问题:C++ QDrag::setDragCursor方法的具体用法?C++ QDrag::setDragCursor怎么用?C++ QDrag::setDragCursor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDrag
的用法示例。
在下文中一共展示了QDrag::setDragCursor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseMoveEvent
void SeView::mouseMoveEvent(QMouseEvent* e)
{
if ((Mpressed) && ((Mpos - e->pos()).manhattanLength() > 4))
{
Mpressed = false;
int a = rowAt(e->pos().y());
int b = columnAt(e->pos().x());
if ((a != -1) && (b != -1))
{
QTableWidgetItem* ite = item(a, b);
if (ite != 0)
{
if (ite->type() == 1002)
{
SeItem* it = (SeItem*)ite;
QString str(it->pageName);
bool dummy;
int p = GetPage(a, b, &dummy);
QString tmp;
QMimeData *mimeData = new QMimeData;
mimeData->setData("page/magic", "2 "+tmp.setNum(p).toLocal8Bit()+" "+str.toLocal8Bit());
mimeData->setText("2 "+tmp.setNum(p)+" "+str);
QDrag *dr = new QDrag(this);
dr->setMimeData(mimeData);
const QPixmap& pm = loadIcon("doc.png");
dr->setDragCursor(pm, Qt::CopyAction);
dr->setDragCursor(pm, Qt::MoveAction);
dr->exec(Qt::CopyAction | Qt::MoveAction);
QApplication::setOverrideCursor(Qt::ArrowCursor);
}
}
}
}
QTableWidget::mouseMoveEvent(e);
}
示例2: startDrag
void DeviceExplorerView::startDrag(Qt::DropActions)
{
QModelIndexList indexes = selectedDraggableIndexes();
if (indexes.count() > 0)
{
QMimeData* data = QTreeView::model()->mimeData(indexes);
if (!data)
return;
QDrag* drag = new QDrag(this);
drag->setMimeData(data);
drag->setPixmap(QPixmap());
drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::CopyAction);
drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::MoveAction);
drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::LinkAction);
drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::ActionMask);
drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::IgnoreAction);
drag->setDragCursor(QCursor{Qt::CrossCursor}.pixmap(), Qt::TargetMoveAction);
drag->exec();
}
}
示例3: QDrag
void
View::DragMeepleLabel::mouseMoveEvent( QMouseEvent * inEvent )
{
if ( !( inEvent->buttons() & Qt::LeftButton ) )
{
return;
}
if ( (inEvent->pos() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance() )
{
return;
}
QDrag * drag = new QDrag( this );
Dragging::PieceData * dragData = new Dragging::PieceData( mMeeple );
drag->setMimeData( dragData );
drag->setPixmap( mPixmap );
drag->setDragCursor( getEmptyPixmap(), Qt::MoveAction );
drag->setHotSpot( QPoint( Gui::kMeepleWidth / 2, Gui::kMeepleHeight / 2 ) );
drag->exec( Qt::MoveAction );
}
示例4: drag
//ドラッグ
void MapFrame::drag()
{
Map* pMap = app.getMap();
IntsecCommon* pic = pMap->getIntsecCommon();
Intsec* pIntsec;
Intsec* pIntsecReplCon;
QPixmap pixmapDrag;
// qDebug("MapFrame::drag start");
_clickDrag = false;
//交差点ドラッグ開始、なしならスクロール
_dragType = scroll;
pIntsec = getIntsecAt(_clickDragX, _clickDragY);
if (pIntsec != NULL)
{
//交差点モードなら交差点移動、表示変更後にフラグ指定でないと画面がずれる
if (app.getMainWindow()->getEditMode() == MainWindow::intsec)
{
changeShowSelect(pIntsec->getIntsecId(), MAP_NOID, MAP_NOID);
pixmapDrag = *(pIntsec->getPixmapLabel());
_dragRoadX = getViewX(pIntsec->getMapPosX());
_dragRoadY = getViewY(pIntsec->getMapPosY());
_dragType = intsec;
}
//単路モードなら単路新規作成、表示変更後にフラグ指定でないと画面がずれる
else if (app.getMainWindow()->getEditMode() == MainWindow::road)
{
changeShowSelect(pIntsec->getIntsecId(), MAP_NOID, MAP_NOID);
pixmapDrag = *(pic->getLabelPixmap(pic->getLabelPixmapId(INTSEC_LT_DEST)));
_dragRoadX = _dragRoadConX = getViewX(pIntsec->getMapPosX());
_dragRoadY = _dragRoadConY = getViewY(pIntsec->getMapPosY());
_dragType = road;
}
//単路付け替えモードなら選択単路を付け替え
else if (app.getMainWindow()->getEditMode() == MainWindow::roadRepl)
{
if (_intsecIdSelect == MAP_NOID || _intsecIdDest == MAP_NOID || _roadIdSelect == MAP_NOID)
return;
if (pIntsec->getIntsecId() == _intsecIdSelect)
_intsecIdReplCon = _intsecIdDest;
else if (pIntsec->getIntsecId() == _intsecIdDest)
_intsecIdReplCon = _intsecIdSelect;
else
return;
pixmapDrag = *(pIntsec->getPixmapLabel());
pIntsecReplCon = pMap->getIntsec(_intsecIdReplCon);
_dragRoadX = getViewX(pIntsec->getMapPosX());
_dragRoadY = getViewY(pIntsec->getMapPosY());
_dragRoadConX = getViewX(pIntsecReplCon->getMapPosX());
_dragRoadConY = getViewY(pIntsecReplCon->getMapPosY());
_dragType = roadRepl;
}
}
//ドラッグ情報設定
if (_dragType == scroll)
{
_intsecIdDrag = MAP_NOID;
_offsetDragX = _offsetDragY = 0;
_scrollBeginMapX = app.getViewMapX();
_scrollBeginMapY = app.getViewMapY();
}
else
{
_intsecIdDrag = pIntsec->getIntsecId();
_offsetDragX = _clickDragX - getViewX(pIntsec->getMapPosX());
_offsetDragY = _clickDragY - getViewY(pIntsec->getMapPosY());
// qDebug("MapFrame::mouseMoveEvent %d (%d,%d) = (%d,%d) - (%d,%d)",
// _intsecIdDrag, _offsetDragX, _offsetDragY, _clickDragX, _clickDragY,
// getViewX(pIntsec->getMapPosX()), getViewY(pIntsec->getMapPosY()));
}
QByteArray itemData;
QMimeData *mimeData = new QMimeData;
mimeData->setData(ITEM_MINETYPE, itemData);
//ドラッグ中表示設定、 デフォルト pixmap の□は消せない、透明色ファイルを置いても透明にならない
// qDebug("MapFrame::mouseMoveEvent setPixmap intsecId=%d", pIntsec->getIntsecId());
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
QPoint pointHotSpot;
if (_dragType == scroll)
{
#ifdef USE_QT5
if (!pixmapDrag)
{
//pixmapDrag = QPixmap(width(), height());
pixmapDrag = QPixmap(1, 1);
}
#endif //USE_QT5
drag->setPixmap(pixmapDrag);
drag->setDragCursor(QPixmap(":/images/scroll_cursor.png"), Qt::MoveAction);
}
else
{
//.........这里部分代码省略.........