504 lines
19 KiB
C++
504 lines
19 KiB
C++
#include "QtDefectSet.h"
|
|
|
|
//海康
|
|
//#include <MvCameraControl.h>
|
|
////大华
|
|
//#pragma comment(lib, "MVSDKmd.lib")
|
|
//#include "IMVApi.h"
|
|
////Basler
|
|
//#include <pylon/PylonIncludes.h>
|
|
//#include <pylon/BaslerUniversalInstantCamera.h>
|
|
////大恒
|
|
//#include <GalaxyIncludes.h>
|
|
//#pragma comment(lib,"./GxIAPICPPEx.lib")
|
|
//////dalsa
|
|
////#include <SapClassBasic.h> //Dalsa相机头文件
|
|
////#include <SapManager.h> //Dalsa相机头文件
|
|
////ITEK
|
|
//#include <IKapC.h>
|
|
//#pragma comment(lib,"./IKapBoard.lib")
|
|
//#pragma comment(lib,"./IKapC.lib")
|
|
////OPT
|
|
//#include "OPTApi.h" //OPT和海康有部分名称一样,OPT时使用海康
|
|
//#pragma comment(lib,"./OPTSDK.lib")
|
|
using namespace std;
|
|
QtDefectSet::QtDefectSet(QMainWindow*parent)
|
|
: QMainWindow(parent)
|
|
{
|
|
ui.setupUi(this);
|
|
//追踪鼠标,写在构造函数中
|
|
this->setMouseTracking(true);
|
|
//ui.centralWidget->setMouseTracking(true);
|
|
ui.title->setMouseTracking(true);
|
|
|
|
ui.label_icon->setStyleSheet("image: url(./Icon/logo_Dongsheng.png);");
|
|
setWindowFlags(Qt::FramelessWindowHint); //隐藏标题栏
|
|
ui.pushButton_min->setText("");
|
|
ui.pushButton_close->setText("");
|
|
ui.pushButton_max->setText("");
|
|
ui.pushButton_min->setStyleSheet("background-color:transparent;image: url(./Icon/min_n.png);");
|
|
ui.pushButton_close->setStyleSheet("background-color:transparent;image: url(./Icon/close_n.png);");
|
|
ui.pushButton_max->setStyleSheet("background-color:transparent;image: url(./Icon/Max_n.png);");
|
|
ui.pushButton_max->hide();
|
|
connect(ui.pushButton_min, &QPushButton::pressed, [=]() {
|
|
this->showMinimized();
|
|
qApp->processEvents();
|
|
});
|
|
connect(ui.pushButton_close, &QPushButton::clicked, [=]() {
|
|
this->close();
|
|
qApp->processEvents();
|
|
});
|
|
|
|
//搜索到的相机列表
|
|
ui.tableWidget->setColumnCount(3);
|
|
QStringList headerLabels;
|
|
headerLabels << "类别序号" << "缺陷名称"<<"是否检测" ;
|
|
ui.tableWidget->setHorizontalHeaderLabels(headerLabels);
|
|
ui.tableWidget->setColumnWidth(0, 100);
|
|
ui.tableWidget->setColumnWidth(1, 200);
|
|
ui.tableWidget->setColumnWidth(2, 150);
|
|
ui.tableWidget->setMouseTracking(true);
|
|
ui.tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); // 整行选中
|
|
ui.tableWidget->horizontalHeader()->setSectionsClickable(false);
|
|
ui.tableWidget->verticalHeader()->hide();
|
|
//ui.tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
|
ui.tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section {background-color:rgb(65,65,65);}");
|
|
//ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); // 不可编辑
|
|
//ui.tableWidget_defectList->setFrameShape(QFrame::NoFrame); // 设置无边框
|
|
//ui.tableWidget_defectList->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
|
//ui.tableWidget->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
|
|
ui.tableWidget->setRowCount(0);
|
|
|
|
myMessage = new QMessageBox;
|
|
|
|
//保存按钮
|
|
connect(ui.pushButton_Save, &QPushButton::clicked, [=]() {
|
|
QJsonArray SaveImgArray;
|
|
QStringList nameList;
|
|
for (int i = 0; i < ui.tableWidget->rowCount(); i++)
|
|
{
|
|
if (ui.tableWidget->item(i, 1)->text().isEmpty() || ui.tableWidget->item(i, 1)->text().contains("请输入"))
|
|
{
|
|
myMessage->information(this, "缺陷名称未填入", "请输入缺陷名称,再保存。");
|
|
return;
|
|
}
|
|
if (nameList.contains(ui.tableWidget->item(i, 1)->text()))
|
|
{
|
|
myMessage->information(this, "重复", "缺陷名称重复,请修改后再保存。");
|
|
return;
|
|
}
|
|
|
|
QJsonObject SaveImgObj;
|
|
SaveImgObj.insert("缺陷类别", ui.tableWidget->item(i, 0)->text());
|
|
SaveImgObj.insert("缺陷名称", ui.tableWidget->item(i, 1)->text());
|
|
if(myQCheckBoxQueue[i]->isChecked())
|
|
SaveImgObj.insert("是否检测", "是");
|
|
else
|
|
SaveImgObj.insert("是否检测", "否");
|
|
SaveImgArray.append(SaveImgObj);
|
|
}
|
|
QJsonObject newprogramObj = programObj;
|
|
newprogramObj.insert("缺陷类别名称设置", SaveImgArray);
|
|
if (newprogramObj != programObj)
|
|
{
|
|
QString tmpDate = QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz");
|
|
BackUp_json_cfg_file_path = currPath + "/config/backup/" + tmpDate + "_" + cfg_name;
|
|
//内存中的数据写到文件
|
|
QJsonDocument olddoc(programObj);
|
|
//将json对象转换成字符串
|
|
QByteArray olddata = olddoc.toJson();
|
|
QFile oldfile(BackUp_json_cfg_file_path);
|
|
oldfile.open(QIODevice::WriteOnly);
|
|
oldfile.write(olddata);
|
|
oldfile.close();
|
|
|
|
//内存中的数据写到文件
|
|
QJsonDocument doc(newprogramObj);
|
|
//将json对象转换成字符串
|
|
QByteArray data = doc.toJson();
|
|
QFile file(json_cfg_file_path);
|
|
file.open(QIODevice::WriteOnly);
|
|
file.write(data);
|
|
file.close();
|
|
|
|
programObj = newprogramObj;
|
|
QStringList moduleKeyList;
|
|
stationArray = programObj.value("工站列表").toArray();
|
|
for (int SA = 0; SA < stationArray.size(); SA++)
|
|
{
|
|
QJsonObject stationObj = stationArray[SA].toObject();
|
|
QString stationKey = stationObj.value("工站名").toString();
|
|
|
|
QJsonArray AlgorithmListArray = stationObj.value("算法列表").toArray();
|
|
for (int AL = 0; AL < AlgorithmListArray.size(); AL++)
|
|
moduleKeyList.append(AlgorithmListArray[AL].toObject().value("算法名称").toString());
|
|
}
|
|
emit reLoadJsonSetParameter(moduleKeyList);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
//添加一行
|
|
connect(ui.pushButton_AddLine, &QPushButton::clicked, [=]() {
|
|
ui.tableWidget->setRowCount(ui.tableWidget->rowCount() + 1);
|
|
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1, 0, new QTableWidgetItem(QString::number(ui.tableWidget->rowCount())));//缺陷类别
|
|
ui.tableWidget->setItem(ui.tableWidget->rowCount() - 1, 1, new QTableWidgetItem("请输入"));//缺陷类别
|
|
ui.tableWidget->item(ui.tableWidget->rowCount() - 1, 0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
|
ui.tableWidget->item(ui.tableWidget->rowCount() - 1, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
|
QCheckBox* ifAddBox = new QCheckBox;
|
|
ifAddBox->setChecked(true);
|
|
myQCheckBoxQueue.enqueue(ifAddBox);
|
|
QWidget* w = new QWidget(this); //创建一个widget
|
|
QHBoxLayout* hLayout = new QHBoxLayout(); //创建布局
|
|
hLayout->addWidget(ifAddBox); //添加checkbox
|
|
hLayout->setMargin(0); //设置边缘距离 否则会很难看
|
|
hLayout->setAlignment(ifAddBox, Qt::AlignCenter); //居中
|
|
w->setLayout(hLayout); //设置widget的布局
|
|
ui.tableWidget->setCellWidget(ui.tableWidget->rowCount() - 1, 2, w);
|
|
});
|
|
|
|
//删除一行
|
|
connect(ui.pushButton_DeleteLine, &QPushButton::clicked, [=]() {
|
|
QMessageBox::StandardButton result = QMessageBox::question(this, "确认?", "确认删除此缺陷名称?");
|
|
if (result == QMessageBox::No)//窗口关掉是No
|
|
return;
|
|
if (ui.tableWidget->currentRow() >= 0 && ui.tableWidget->currentRow() < ui.tableWidget->rowCount())
|
|
{
|
|
myQCheckBoxQueue.removeAt(ui.tableWidget->currentRow());
|
|
ui.tableWidget->removeRow(ui.tableWidget->currentRow());
|
|
}
|
|
for (int i = 0; i < ui.tableWidget->rowCount(); i++)
|
|
{
|
|
ui.tableWidget->setItem(i, 0, new QTableWidgetItem(QString::number(i + 1)));//缺陷类别
|
|
ui.tableWidget->item(i, 0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
QtDefectSet::~QtDefectSet()
|
|
{}
|
|
|
|
|
|
void QtDefectSet::setJsonName(QString jsonName)
|
|
{
|
|
ui.tableWidget->setRowCount(0);
|
|
myQCheckBoxQueue.clear();
|
|
QJsonObject current_programObj = load_camera_cfg(jsonName);
|
|
//解析
|
|
QJsonArray DefectNamesArray = current_programObj.value("缺陷类别名称设置").toArray();
|
|
for (int a = 0; a < DefectNamesArray.size(); a++)
|
|
{
|
|
QJsonObject DefectNameObj = DefectNamesArray[a].toObject();
|
|
ui.tableWidget->setRowCount(ui.tableWidget->rowCount() + 1);
|
|
ui.tableWidget->setItem(ui.tableWidget->rowCount() - 1, 0, new QTableWidgetItem(DefectNameObj.value("缺陷类别").toString()));//缺陷类别
|
|
ui.tableWidget->setItem(ui.tableWidget->rowCount() - 1, 1, new QTableWidgetItem(DefectNameObj.value("缺陷名称").toString()));//缺陷名称//居中
|
|
ui.tableWidget->item(ui.tableWidget->rowCount() - 1, 0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
|
ui.tableWidget->item(ui.tableWidget->rowCount() - 1, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
|
QCheckBox* ifAddBox = new QCheckBox;
|
|
if (DefectNameObj.value("是否检测").toString() == "是")
|
|
ifAddBox->setChecked(true);
|
|
myQCheckBoxQueue.enqueue(ifAddBox);
|
|
QWidget* w = new QWidget(this); //创建一个widget
|
|
QHBoxLayout* hLayout = new QHBoxLayout(); //创建布局
|
|
hLayout->addWidget(ifAddBox); //添加checkbox
|
|
hLayout->setMargin(0); //设置边缘距离 否则会很难看
|
|
hLayout->setAlignment(ifAddBox, Qt::AlignCenter); //居中
|
|
w->setLayout(hLayout); //设置widget的布局
|
|
ui.tableWidget->setCellWidget(ui.tableWidget->rowCount() - 1, 2, w);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
QJsonObject QtDefectSet::load_camera_cfg(QString cfg)
|
|
{
|
|
cfg_name = cfg;
|
|
QDir dir = QApplication::applicationDirPath();
|
|
currPath = dir.path();
|
|
json_cfg_file_path = currPath + "/config/" + cfg;//camera_cfg.json";
|
|
QString tmpDate = QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss-zzz");
|
|
BackUp_json_cfg_file_path = currPath + "/config/backup/" + tmpDate + "_" + cfg;
|
|
|
|
QJsonObject json_object;
|
|
try
|
|
{
|
|
QJsonParseError jsonError;
|
|
if (json_cfg_file_path.isEmpty())
|
|
{
|
|
qCritical() << __FUNCTION__ << " line:" << __LINE__ << " JsonPath is null!";
|
|
return json_object;
|
|
}
|
|
|
|
QFile JsonFile;
|
|
JsonFile.setFileName(json_cfg_file_path);
|
|
if (!JsonFile.isReadable())
|
|
{
|
|
qCritical() << __FUNCTION__ << " line:" << __LINE__ << " camera_cfg.json not isReadable!";
|
|
//return json_object;
|
|
}
|
|
JsonFile.open(QIODevice::ReadOnly);
|
|
|
|
QByteArray m_Byte = JsonFile.readAll();
|
|
if (m_Byte.isEmpty())
|
|
{
|
|
qDebug() << __FUNCTION__ << " line:" << __LINE__ << json_cfg_file_path + " Content is empty";
|
|
JsonFile.close();
|
|
return json_object;
|
|
}
|
|
|
|
QJsonDocument jsonDocument(QJsonDocument::fromJson(m_Byte, &jsonError));
|
|
|
|
if (!jsonDocument.isNull() && jsonError.error == QJsonParseError::NoError)
|
|
{
|
|
if (jsonDocument.isObject())
|
|
{
|
|
json_object = jsonDocument.object();
|
|
JsonFile.close();
|
|
programObj = json_object;
|
|
return json_object;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
qCritical() << __FUNCTION__ << " line:" << __LINE__ << json_cfg_file_path + " is error!";
|
|
}
|
|
JsonFile.close();
|
|
|
|
}
|
|
catch (QString ev)
|
|
{
|
|
qCritical() << __FUNCTION__ << " line:" << __LINE__ << " ev:" << ev;
|
|
}
|
|
programObj = json_object;
|
|
return json_object;
|
|
}
|
|
|
|
|
|
|
|
#define MOUSE_MARGIN 3
|
|
//计算鼠标位置
|
|
QtDefectSet::MousePoss QtDefectSet::calcmouseposs(QPoint p)
|
|
{
|
|
QtDefectSet::MousePoss mp;
|
|
if (p.x() < MOUSE_MARGIN && p.y() < MOUSE_MARGIN)
|
|
mp = QtDefectSet::MousePoss::LeftUp; //左上
|
|
else if (p.x() > MOUSE_MARGIN && p.y() < MOUSE_MARGIN && p.x() < this->width() - MOUSE_MARGIN)
|
|
mp = QtDefectSet::MousePoss::Up; //上
|
|
else if (p.x() > this->width() - MOUSE_MARGIN && p.y() < MOUSE_MARGIN)
|
|
mp = QtDefectSet::MousePoss::RightUp; //右上
|
|
else if (p.x() > this->width() - MOUSE_MARGIN && p.y() > MOUSE_MARGIN && p.y() < this->height() - MOUSE_MARGIN)
|
|
mp = QtDefectSet::MousePoss::Right; //右
|
|
else if (p.x() > this->width() - MOUSE_MARGIN && p.y() > this->height() - MOUSE_MARGIN)
|
|
mp = QtDefectSet::MousePoss::RightDown; //右下
|
|
else if (p.x() > MOUSE_MARGIN && p.x() < this->width() - MOUSE_MARGIN && p.y() > this->height() - MOUSE_MARGIN)
|
|
mp = QtDefectSet::MousePoss::Down; //下
|
|
else if (p.x() < MOUSE_MARGIN && p.y() > this->height() - MOUSE_MARGIN)
|
|
mp = QtDefectSet::MousePoss::LeftDown; //左下
|
|
else if (p.x() < MOUSE_MARGIN && p.y() < this->height() - MOUSE_MARGIN && p.y() > MOUSE_MARGIN)
|
|
mp = QtDefectSet::MousePoss::Left; //左
|
|
else
|
|
mp = QtDefectSet::MousePoss::Middle; //中间
|
|
return mp;
|
|
}
|
|
//修改鼠标样式
|
|
void QtDefectSet::setCursorType(QtDefectSet::MousePoss type)
|
|
{
|
|
Qt::CursorShape cursor;
|
|
switch (type)
|
|
{
|
|
case QtDefectSet::MousePoss::LeftUp:
|
|
case QtDefectSet::MousePoss::RightDown:
|
|
cursor = Qt::SizeFDiagCursor;
|
|
break;
|
|
case QtDefectSet::MousePoss::Up:
|
|
case QtDefectSet::MousePoss::Down:
|
|
cursor = Qt::SizeVerCursor;
|
|
break;
|
|
case QtDefectSet::MousePoss::RightUp:
|
|
case QtDefectSet::MousePoss::LeftDown:
|
|
cursor = Qt::SizeBDiagCursor;
|
|
break;
|
|
case QtDefectSet::MousePoss::Right:
|
|
case QtDefectSet::MousePoss::Left:
|
|
cursor = Qt::SizeHorCursor;
|
|
break;
|
|
default:
|
|
cursor = Qt::ArrowCursor;
|
|
break;
|
|
}
|
|
setCursor(cursor);
|
|
}
|
|
//改变窗口的大小
|
|
void QtDefectSet::changeWindowSize(QtDefectSet::MousePoss type, QRect& wid, QPoint ptemp, int minWidth, int minHeight)
|
|
{
|
|
switch (type)//改变窗口的大小
|
|
{
|
|
case QtDefectSet::MousePoss::LeftUp:
|
|
{
|
|
QPoint pos = wid.topLeft();
|
|
|
|
if (wid.width() > minWidth || ptemp.x() < 0)
|
|
pos.rx() = pos.rx() + ptemp.x();
|
|
if (wid.height() > minHeight || ptemp.y() < 0)
|
|
pos.ry() = pos.ry() + ptemp.y();
|
|
|
|
wid.setTopLeft(pos);
|
|
break;//左上角
|
|
}
|
|
case QtDefectSet::MousePoss::RightUp:
|
|
{
|
|
QPoint pos = wid.topRight();
|
|
|
|
if (wid.width() > minWidth || ptemp.x() > 0)
|
|
pos.rx() = pos.rx() + ptemp.x();
|
|
if (wid.height() > minHeight || ptemp.y() < 0)
|
|
pos.ry() = pos.ry() + ptemp.y();
|
|
|
|
wid.setTopRight(pos);
|
|
break;//右上角
|
|
}
|
|
case QtDefectSet::MousePoss::LeftDown:
|
|
{
|
|
QPoint pos = wid.bottomLeft();
|
|
|
|
if (wid.width() > minWidth || ptemp.x() < 0)
|
|
pos.rx() = pos.rx() + ptemp.x();
|
|
if (wid.height() > minHeight || ptemp.y() > 0)
|
|
pos.ry() = pos.ry() + ptemp.y();
|
|
|
|
wid.setBottomLeft(pos);
|
|
break;//左下角
|
|
}
|
|
case QtDefectSet::MousePoss::RightDown:
|
|
{
|
|
QPoint pos = wid.bottomRight();
|
|
|
|
if (wid.width() > minWidth || ptemp.x() > 0)
|
|
pos.rx() = pos.rx() + ptemp.x();
|
|
if (wid.height() > minHeight || ptemp.y() > 0)
|
|
pos.ry() = pos.ry() + ptemp.y();
|
|
|
|
wid.setBottomRight(pos);
|
|
break;//右下角
|
|
}
|
|
case QtDefectSet::MousePoss::Up:
|
|
{
|
|
int topY = wid.top();
|
|
if (wid.height() > minHeight || ptemp.y() < 0)
|
|
topY = topY + ptemp.y();
|
|
|
|
wid.setTop(topY);
|
|
break;//上
|
|
}
|
|
case QtDefectSet::MousePoss::Left:
|
|
{
|
|
int leftX = wid.left();
|
|
|
|
if (wid.width() > minWidth || ptemp.x() < 0)
|
|
leftX = leftX + ptemp.x();
|
|
|
|
wid.setLeft(leftX);
|
|
break;//左
|
|
}
|
|
case QtDefectSet::MousePoss::Right:
|
|
{
|
|
int rightX = wid.right();
|
|
|
|
if (wid.width() > minWidth || ptemp.x() > 0)
|
|
rightX = rightX + ptemp.x();
|
|
|
|
wid.setRight(rightX);
|
|
break;//右
|
|
}
|
|
case QtDefectSet::MousePoss::Down:
|
|
{
|
|
int botY = wid.bottom();
|
|
if (wid.height() > minHeight || ptemp.y() > 0)
|
|
botY = botY + ptemp.y();
|
|
|
|
wid.setBottom(botY);
|
|
break;//下
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
//三个鼠标事件的重写
|
|
void QtDefectSet::mousePressEvent(QMouseEvent* e)
|
|
{
|
|
|
|
if (e->button() == Qt::LeftButton) //鼠标左键按下
|
|
{
|
|
m_lastPos = e->globalPos();
|
|
e->ignore();
|
|
}
|
|
|
|
|
|
}
|
|
//鼠标移动
|
|
void QtDefectSet::mouseMoveEvent(QMouseEvent* e)
|
|
{
|
|
//最大化状态,鼠标是否在标题栏,拖拽还原
|
|
if (this->isMaximized())
|
|
{
|
|
if (ui.title->geometry().contains(this->mapFromGlobal(QCursor::pos())) && e->buttons() == Qt::LeftButton)
|
|
{
|
|
QPoint ptemp = e->globalPos();
|
|
if (ptemp != m_lastPos)
|
|
{
|
|
this->showNormal();
|
|
}
|
|
}
|
|
}
|
|
QtDefectSet::MousePoss curPos = calcmouseposs(e->pos());
|
|
if (!e->buttons())
|
|
{
|
|
setCursorType(curPos);
|
|
mp_curPos = curPos;
|
|
}
|
|
|
|
if (e->buttons() == Qt::LeftButton) //坐标左键按下并移动
|
|
{
|
|
QPoint ptemp = e->globalPos();
|
|
ptemp = ptemp - m_lastPos; //鼠标移动的偏移量
|
|
if (mp_curPos == QtDefectSet::MousePoss::Middle && ui.title->geometry().contains(this->mapFromGlobal(QCursor::pos()))
|
|
&& !ui.pushButton_max->geometry().contains(this->mapFromGlobal(QCursor::pos()))
|
|
&& !ui.pushButton_min->geometry().contains(this->mapFromGlobal(QCursor::pos()))
|
|
&& !ui.pushButton_close->geometry().contains(this->mapFromGlobal(QCursor::pos())))
|
|
{
|
|
move(ptemp + pos());
|
|
}
|
|
else
|
|
{
|
|
QRect wid = geometry();
|
|
int minWidth = this->minimumWidth();
|
|
int minHeight = this->minimumHeight();
|
|
if (ptemp.x() < 50 && ptemp.x() > -50)
|
|
{
|
|
changeWindowSize(mp_curPos, wid, ptemp, minWidth, minHeight);
|
|
//更新大小
|
|
setGeometry(wid);
|
|
}
|
|
}
|
|
m_lastPos = e->globalPos();
|
|
}
|
|
e->ignore();
|
|
}
|
|
//鼠标释放
|
|
void QtDefectSet::mouseReleaseEvent(QMouseEvent* e)
|
|
{
|
|
if (e->button() == Qt::LeftButton && ui.title->geometry().contains(this->mapFromGlobal(QCursor::pos()))
|
|
&& !ui.pushButton_max->geometry().contains(this->mapFromGlobal(QCursor::pos()))
|
|
&& !ui.pushButton_min->geometry().contains(this->mapFromGlobal(QCursor::pos()))
|
|
&& !ui.pushButton_close->geometry().contains(this->mapFromGlobal(QCursor::pos()))) //鼠标左键释放
|
|
{
|
|
int dx = e->globalX() - m_lastPos.x();
|
|
int dy = e->globalY() - m_lastPos.y();
|
|
move(x() + dx, y() + dy);
|
|
}
|
|
QApplication::restoreOverrideCursor();//恢复鼠标指针性状
|
|
e->ignore();
|
|
} |