1 Star 0 Fork 142

撸码小分队/DS

forked from Vanishi/DS 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mFlowMenuToolbutton.cpp 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
sun-th 提交于 2023-03-18 16:17 +08:00 . 1.0
#include "mFlowMenuToolbutton.h"
#include "TaskFlow/mFcModels.h"
#include <QMimeData>
#include <QDrag>
#include <QMouseEvent>
MFlowMenuToolButton::MFlowMenuToolButton(QWidget *parent,MControl * control) : QToolButton(parent)
{
this->data = new MFlowStepData(control,nullptr);
this->data->widget = this;
setStyleSheet(".MFlowMenuToolButton{border:0px;}");
setCursor(Qt::PointingHandCursor);// 手指
setToolTip(control->menuTip);
QSize s(36,30);
setFixedSize(s);
setIconSize(s);
setIcon(QIcon(control->menuIcon));
}
void MFlowMenuToolButton::mousePressEvent(QMouseEvent *event){
this->data->notificationType=MCONNSTANT_NOTIFICATION_TYPE_START;
emit this->notificationToParentWidget(this->data);
QPoint offset = event->pos();
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
dataStream << offset;
QMimeData *mimeData = new QMimeData();
mimeData->setData("application/MFlowMenuToolButton", itemData);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->setPixmap(this->icon().pixmap(30,30));
// drag->setHotSpot(offset);
if (drag->exec(Qt::MoveAction) == Qt::MoveAction) {
this->data->notificationType=MCONNSTANT_NOTIFICATION_TYPE_MOVE_END_SHOWCONTENT;
emit this->notificationToParentWidget(this->data);
} else {
this->data->notificationType=MCONNSTANT_NOTIFICATION_TYPE_OTHER_END;
emit this->notificationToParentWidget(this->data);
}
}
MFlowMenuToolButton::~MFlowMenuToolButton(){
data->widgetIsDelete = true;
delete data;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/coderanks/DS.git
git@gitee.com:coderanks/DS.git
coderanks
DS
DS
master

搜索帮助