更新代码

This commit is contained in:
feiyangqingyun
2023-01-30 11:41:50 +08:00
parent 890c06d443
commit d35ca11ee2
30 changed files with 85 additions and 68 deletions

View File

@@ -218,7 +218,7 @@ void DeviceSizeTable::checkSize(const QString &result, const QString &name)
QStringList list = result.split(" ");
int index = 0;
for (int i = 0; i < list.count(); ++i) {
for (int i = 0; i < list.size(); ++i) {
QString s = list.at(i).trimmed();
if (s.isEmpty()) {
continue;

View File

@@ -136,7 +136,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
int fontId = fontDb.addApplicationFont(fontFile);
QStringList listName = fontDb.applicationFontFamilies(fontId);
if (listName.count() == 0) {
if (listName.size() == 0) {
qDebug() << QString("load %1 error").arg(fontName);
}
}
@@ -265,8 +265,8 @@ void IconHelper::setStyle1(QWidget *widget, QList<QToolButton *> btns, QList<int
void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor)
{
int btnCount = btns.count();
int iconCount = icons.count();
int btnCount = btns.size();
int iconCount = icons.size();
if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) {
return;
}
@@ -329,7 +329,7 @@ void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList
//可能会重复调用设置所以先要移除上一次的
for (int i = 0; i < btnCount; ++i) {
for (int j = 0; j < this->btns.count(); j++) {
for (int j = 0; j < this->btns.size(); j++) {
if (this->btns.at(j) == btns.at(i)) {
disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
this->btns.at(j)->removeEventFilter(this);

View File

@@ -114,7 +114,7 @@ SaveLog::SaveLog(QObject *parent) : QObject(parent)
//默认取应用程序可执行文件名称
QString str = qApp->applicationFilePath();
QStringList list = str.split("/");
name = list.at(list.count() - 1).split(".").at(0);
name = list.at(list.size() - 1).split(".").at(0);
fileName = "";
//默认所有类型都输出

View File

@@ -28,7 +28,7 @@ SaveRunTime::SaveRunTime(QObject *parent) : QObject(parent)
path = qApp->applicationDirPath();
QString str = qApp->applicationFilePath();
QStringList list = str.split("/");
name = list.at(list.count() - 1).split(".").at(0);
name = list.at(list.size() - 1).split(".").at(0);
saveInterval = 1 * 60 * 1000;
startTime = QDateTime::currentDateTime();
@@ -187,7 +187,7 @@ void SaveRunTime::saveLog()
//重新清空文件
file.resize(0);
//如果行数小于2则返回
if (content.count() < 2) {
if (content.size() < 2) {
file.close();
return;
}
@@ -206,7 +206,7 @@ void SaveRunTime::saveLog()
lastLine = list.join("\t");
//重新替换最后一行并写入新的数据
content[content.count() - 1] = lastLine;
content[content.size() - 1] = lastLine;
QTextStream stream(&file);
stream << content.join("") << "\n";

View File

@@ -24,13 +24,13 @@ QPainterPath SmoothCurve::createSmoothCurve(const QVector<QPointF> &points)
QPainterPath SmoothCurve::createSmoothCurve2(const QVector<QPointF> &points)
{
//采用Qt原生方法不做任何处理
int count = points.count();
if (count == 0) {
int size = points.size();
if (size == 0) {
return QPainterPath();
}
QPainterPath path(points.at(0));
for (int i = 0; i < count - 1; ++i) {
for (int i = 0; i < size - 1; ++i) {
//控制点的 x 坐标为 sp 与 ep 的 x 坐标和的一半
//第一个控制点 c1 的 y 坐标为起始点 sp 的 y 坐标
//第二个控制点 c2 的 y 坐标为结束点 ep 的 y 坐标

View File

@@ -250,7 +250,7 @@ void ZhToPY::loadPY(const QString &fileName)
QString ZhToPY::zhToPY(const QString &chinese)
{
if (listPY.count() == 0) {
if (listPY.size() == 0) {
return "";
}

View File

@@ -24,13 +24,13 @@ QPainterPath SmoothCurve::createSmoothCurve(const QVector<QPointF> &points)
QPainterPath SmoothCurve::createSmoothCurve2(const QVector<QPointF> &points)
{
//采用Qt原生方法不做任何处理
int count = points.count();
if (count == 0) {
int size = points.size();
if (size == 0) {
return QPainterPath();
}
QPainterPath path(points.at(0));
for (int i = 0; i < count - 1; ++i) {
for (int i = 0; i < size - 1; ++i) {
//控制点的 x 坐标为 sp 与 ep 的 x 坐标和的一半
//第一个控制点 c1 的 y 坐标为起始点 sp 的 y 坐标
//第二个控制点 c2 的 y 坐标为结束点 ep 的 y 坐标

View File

@@ -136,7 +136,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
int fontId = fontDb.addApplicationFont(fontFile);
QStringList listName = fontDb.applicationFontFamilies(fontId);
if (listName.count() == 0) {
if (listName.size() == 0) {
qDebug() << QString("load %1 error").arg(fontName);
}
}
@@ -265,8 +265,8 @@ void IconHelper::setStyle1(QWidget *widget, QList<QToolButton *> btns, QList<int
void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor)
{
int btnCount = btns.count();
int iconCount = icons.count();
int btnCount = btns.size();
int iconCount = icons.size();
if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) {
return;
}
@@ -329,7 +329,7 @@ void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList
//可能会重复调用设置所以先要移除上一次的
for (int i = 0; i < btnCount; ++i) {
for (int j = 0; j < this->btns.count(); j++) {
for (int j = 0; j < this->btns.size(); j++) {
if (this->btns.at(j) == btns.at(i)) {
disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
this->btns.at(j)->removeEventFilter(this);

View File

@@ -136,7 +136,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
int fontId = fontDb.addApplicationFont(fontFile);
QStringList listName = fontDb.applicationFontFamilies(fontId);
if (listName.count() == 0) {
if (listName.size() == 0) {
qDebug() << QString("load %1 error").arg(fontName);
}
}
@@ -265,8 +265,8 @@ void IconHelper::setStyle1(QWidget *widget, QList<QToolButton *> btns, QList<int
void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor)
{
int btnCount = btns.count();
int iconCount = icons.count();
int btnCount = btns.size();
int iconCount = icons.size();
if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) {
return;
}
@@ -329,7 +329,7 @@ void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList
//可能会重复调用设置所以先要移除上一次的
for (int i = 0; i < btnCount; ++i) {
for (int j = 0; j < this->btns.count(); j++) {
for (int j = 0; j < this->btns.size(); j++) {
if (this->btns.at(j) == btns.at(i)) {
disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
this->btns.at(j)->removeEventFilter(this);

Binary file not shown.

Binary file not shown.

View File

@@ -136,7 +136,7 @@ IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject
if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) {
int fontId = fontDb.addApplicationFont(fontFile);
QStringList listName = fontDb.applicationFontFamilies(fontId);
if (listName.count() == 0) {
if (listName.size() == 0) {
qDebug() << QString("load %1 error").arg(fontName);
}
}
@@ -265,8 +265,8 @@ void IconHelper::setStyle1(QWidget *widget, QList<QToolButton *> btns, QList<int
void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList<int> icons, const IconHelper::StyleColor &styleColor)
{
int btnCount = btns.count();
int iconCount = icons.count();
int btnCount = btns.size();
int iconCount = icons.size();
if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) {
return;
}
@@ -329,7 +329,7 @@ void IconHelper::setStyle1(QWidget *widget, QList<QAbstractButton *> btns, QList
//可能会重复调用设置所以先要移除上一次的
for (int i = 0; i < btnCount; ++i) {
for (int j = 0; j < this->btns.count(); j++) {
for (int j = 0; j < this->btns.size(); j++) {
if (this->btns.at(j) == btns.at(i)) {
disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
this->btns.at(j)->removeEventFilter(this);

View File

@@ -30,6 +30,9 @@ PanelWidget::PanelWidget(QWidget *parent) : QWidget(parent)
scrollArea->setWidget(scrollAreaContents);
frame->setStyleSheet("QFrame#frameMain{border-width:0px;}");
hSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
vSpacer = new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding);
margin = 0;
space = 0;
autoWidth = false;
@@ -133,12 +136,16 @@ void PanelWidget::loadWidgets()
int column = 0;
int index = 0;
//先把之前的所有移除并不可见
//先把之前的所有移除并不可见
foreach (QWidget *widget, widgets) {
gridLayout->removeWidget(widget);
widget->setVisible(false);
}
//移除所有弹簧
gridLayout->removeItem(hSpacer);
gridLayout->removeItem(vSpacer);
//重新添加到布局中并可见
foreach (QWidget *widget, widgets) {
gridLayout->addWidget(widget, row, column);
@@ -156,13 +163,11 @@ void PanelWidget::loadWidgets()
//设置右边弹簧
if (!autoWidth) {
QSpacerItem *hSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
gridLayout->addItem(hSpacer, 0, gridLayout->columnCount());
}
//设置底边弹簧
if (!autoHeight) {
QSpacerItem *vSpacer = new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding);
gridLayout->addItem(vSpacer, row, 0);
}
}

View File

@@ -16,6 +16,7 @@ class QScrollArea;
class QFrame;
class QVBoxLayout;
class QGridLayout;
class QSpacerItem;
#ifdef quc
class Q_DECL_EXPORT PanelWidget : public QWidget
@@ -43,6 +44,8 @@ private:
QFrame *frame; //放置设备的框架,自动变宽变高
QVBoxLayout *verticalLayout; //设备面板总布局
QGridLayout *gridLayout; //设备表格布局
QSpacerItem *hSpacer; //横向弹簧
QSpacerItem *vSpacer; //垂直弹簧
int margin; //边距
int space; //设备之间的间隔

View File

@@ -253,7 +253,7 @@ void FFmpegThread::run()
continue;
}
frameFinish = avcodec_receive_frame(videoCodec, avFrame2);
frameFinish = avcodec_receive_frame(videoCodec, avFrame2);
if (frameFinish < 0) {
continue;
}
@@ -383,7 +383,16 @@ void FFmpegWidget::paintEvent(QPaintEvent *)
//qDebug() << TIMEMS << "paintEvent" << objectName();
QPainter painter(this);
#if 0
//image = image.scaled(this->size(), Qt::KeepAspectRatio);
//按照比例自动居中绘制
int pixX = rect().center().x() - image.width() / 2;
int pixY = rect().center().y() - image.height() / 2;
QPoint point(pixX, pixY);
painter.drawImage(point, image);
#else
painter.drawImage(this->rect(), image);
#endif
}
void FFmpegWidget::updateImage(const QImage &image)

View File

@@ -1,7 +1,7 @@
### 特别说明
1. 编译完成以后记得将动态库文件复制到可执行文件同一目录。
2. 动态库地址:[https://pan.baidu.com/s/13LDRu6mXC6gaADtrGprNVA](https://pan.baidu.com/s/13LDRu6mXC6gaADtrGprNVA) 提取码: ujm7
3. 收费增强版:[https://qtchina.blog.csdn.net/article/details/103946731](https://qtchina.blog.csdn.net/article/details/103946731)
3. 收费增强版:[https://qtchina.blog.csdn.net/article/details/103946067](https://qtchina.blog.csdn.net/article/details/103946067)
### 其他说明
1. 作品大全:[https://qtchina.blog.csdn.net/article/details/97565652](https://qtchina.blog.csdn.net/article/details/97565652)

View File

@@ -7,7 +7,7 @@ Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
ui->setupUi(this);
QStringList urls;
urls << "https://hls01open.ys7.com/openlive/6e0b2be040a943489ef0b9bb344b96b8.hd.m3u8";
urls << "f:/1.mp4";
urls << "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
urls << "http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4";
urls << "rtsp://admin:Admin123456@192.168.0.15:554/media/video1";

View File

@@ -1,7 +1,7 @@
### 特别说明
1. 编译完成以后记得将dll文件复制到可执行文件同一目录。
2. 动态库地址:[https://pan.baidu.com/s/13LDRu6mXC6gaADtrGprNVA](https://pan.baidu.com/s/13LDRu6mXC6gaADtrGprNVA) 提取码: ujm7
3. 收费增强版:[https://qtchina.blog.csdn.net/article/details/107972067](https://qtchina.blog.csdn.net/article/details/107972067)
3. 收费增强版:[https://qtchina.blog.csdn.net/article/details/103946067](https://qtchina.blog.csdn.net/article/details/103946067)
### 其他说明
1. 作品大全:[https://qtchina.blog.csdn.net/article/details/97565652](https://qtchina.blog.csdn.net/article/details/97565652)

View File

@@ -37,7 +37,7 @@ void VideoBox::addMenu(QMenu *menu, int type)
//超过一个子元素则添加子菜单
QMenu *menuSub;
if (flags.count() > 1) {
if (flags.size() > 1) {
menuSub = menu->addMenu(name);
} else {
menuSub = menu;
@@ -50,7 +50,7 @@ void VideoBox::addMenu(QMenu *menu, int type)
//对应菜单文本
QString text = QString("%1%2-%1%3").arg(actionFlag).arg(start).arg(end);
if (flags.count() == 1) {
if (flags.size() == 1) {
text = name;
}
@@ -76,7 +76,7 @@ void VideoBox::setLayout(QGridLayout *gridLayout)
void VideoBox::setWidgets(QWidgetList widgets)
{
this->widgets = widgets;
this->videoCount = widgets.count();
this->videoCount = widgets.size();
}
void VideoBox::setMenuFlag(const QString &menuFlag)
@@ -97,7 +97,7 @@ void VideoBox::setTypes(const QMap<int, QStringList> &types)
void VideoBox::initMenu(QMenu *menu, const QList<bool> &enable)
{
//通过菜单是否可见设置每个菜单可见与否
if (enable.count() < 9) {
if (enable.size() < 9) {
return;
}
@@ -209,7 +209,7 @@ void VideoBox::change_video_normal(int index, int flag)
{
//首先隐藏所有通道
hide_video_all();
int count = 0;
int size = 0;
int row = 0;
int column = 0;
@@ -221,7 +221,7 @@ void VideoBox::change_video_normal(int index, int flag)
gridLayout->addWidget(widgets.at(i), row, column);
widgets.at(i)->setVisible(true);
count++;
size++;
column++;
if (column == flag) {
row++;
@@ -229,7 +229,7 @@ void VideoBox::change_video_normal(int index, int flag)
}
}
if (count == (flag * flag)) {
if (size == (flag * flag)) {
break;
}
}
@@ -255,7 +255,7 @@ void VideoBox::change_video_custom(int index, int type)
void VideoBox::change_video_6(const QList<int> &indexs)
{
//过滤防止索引越界
if (indexs.count() < 6) {
if (indexs.size() < 6) {
return;
}
@@ -277,7 +277,7 @@ void VideoBox::change_video_6(const QList<int> &indexs)
void VideoBox::change_video_8(const QList<int> &indexs)
{
//过滤防止索引越界
if (indexs.count() < 8) {
if (indexs.size() < 8) {
return;
}
@@ -301,7 +301,7 @@ void VideoBox::change_video_8(const QList<int> &indexs)
void VideoBox::change_video_13(const QList<int> &indexs)
{
//过滤防止索引越界
if (indexs.count() < 13) {
if (indexs.size() < 13) {
return;
}

View File

@@ -37,7 +37,7 @@ void VideoBox::addMenu(QMenu *menu, int type)
//超过一个子元素则添加子菜单
QMenu *menuSub;
if (flags.count() > 1) {
if (flags.size() > 1) {
menuSub = menu->addMenu(name);
} else {
menuSub = menu;
@@ -50,7 +50,7 @@ void VideoBox::addMenu(QMenu *menu, int type)
//对应菜单文本
QString text = QString("%1%2-%1%3").arg(actionFlag).arg(start).arg(end);
if (flags.count() == 1) {
if (flags.size() == 1) {
text = name;
}
@@ -76,7 +76,7 @@ void VideoBox::setLayout(QGridLayout *gridLayout)
void VideoBox::setWidgets(QWidgetList widgets)
{
this->widgets = widgets;
this->videoCount = widgets.count();
this->videoCount = widgets.size();
}
void VideoBox::setMenuFlag(const QString &menuFlag)
@@ -97,7 +97,7 @@ void VideoBox::setTypes(const QMap<int, QStringList> &types)
void VideoBox::initMenu(QMenu *menu, const QList<bool> &enable)
{
//通过菜单是否可见设置每个菜单可见与否
if (enable.count() < 9) {
if (enable.size() < 9) {
return;
}
@@ -209,7 +209,7 @@ void VideoBox::change_video_normal(int index, int flag)
{
//首先隐藏所有通道
hide_video_all();
int count = 0;
int size = 0;
int row = 0;
int column = 0;
@@ -221,7 +221,7 @@ void VideoBox::change_video_normal(int index, int flag)
gridLayout->addWidget(widgets.at(i), row, column);
widgets.at(i)->setVisible(true);
count++;
size++;
column++;
if (column == flag) {
row++;
@@ -229,7 +229,7 @@ void VideoBox::change_video_normal(int index, int flag)
}
}
if (count == (flag * flag)) {
if (size == (flag * flag)) {
break;
}
}
@@ -255,7 +255,7 @@ void VideoBox::change_video_custom(int index, int type)
void VideoBox::change_video_6(const QList<int> &indexs)
{
//过滤防止索引越界
if (indexs.count() < 6) {
if (indexs.size() < 6) {
return;
}
@@ -277,7 +277,7 @@ void VideoBox::change_video_6(const QList<int> &indexs)
void VideoBox::change_video_8(const QList<int> &indexs)
{
//过滤防止索引越界
if (indexs.count() < 8) {
if (indexs.size() < 8) {
return;
}
@@ -301,7 +301,7 @@ void VideoBox::change_video_8(const QList<int> &indexs)
void VideoBox::change_video_13(const QList<int> &indexs)
{
//过滤防止索引越界
if (indexs.count() < 13) {
if (indexs.size() < 13) {
return;
}

Binary file not shown.

View File

@@ -109,7 +109,7 @@ void VideoWindow::initFlowPanel()
if (!fontDb.families().contains("iconfont")) {
int fontId = fontDb.addApplicationFont(":/font/iconfont.ttf");
QStringList fontName = fontDb.applicationFontFamilies(fontId);
if (fontName.count() == 0) {
if (fontName.size() == 0) {
qDebug() << "load iconfont.ttf error";
}
}
@@ -124,7 +124,7 @@ void VideoWindow::initFlowPanel()
#endif
//循环添加顶部按钮
for (int i = 0; i < btns.count(); ++i) {
for (int i = 0; i < btns.size(); ++i) {
QPushButton *btn = new QPushButton;
//绑定按钮单击事件,用来发出信号通知
connect(btn, SIGNAL(clicked(bool)), this, SLOT(btnClicked()));
@@ -208,7 +208,7 @@ void VideoWindow::dropEvent(QDropEvent *event)
url = event->mimeData()->urls().first().toLocalFile();
} else if (event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
QTreeWidget *treeWidget = (QTreeWidget *)event->source();
if (treeWidget != 0) {
if (treeWidget) {
url = treeWidget->currentItem()->data(0, Qt::UserRole).toString();
}
}

View File

@@ -319,7 +319,7 @@ bool FramelessDialog::nativeEvent(const QByteArray &eventType, void *message, lo
}
//识别标题栏拖动产生半屏全屏效果
if (titleBar != 0 && titleBar->rect().contains(pos)) {
if (titleBar && titleBar->rect().contains(pos)) {
QWidget *child = titleBar->childAt(pos);
if (!child) {
*result = HTCAPTION;

View File

@@ -319,7 +319,7 @@ bool FramelessMainWindow::nativeEvent(const QByteArray &eventType, void *message
}
//识别标题栏拖动产生半屏全屏效果
if (titleBar != 0 && titleBar->rect().contains(pos)) {
if (titleBar && titleBar->rect().contains(pos)) {
QWidget *child = titleBar->childAt(pos);
if (!child) {
*result = HTCAPTION;

View File

@@ -319,7 +319,7 @@ bool FramelessWidget::nativeEvent(const QByteArray &eventType, void *message, lo
}
//识别标题栏拖动产生半屏全屏效果
if (titleBar != 0 && titleBar->rect().contains(pos)) {
if (titleBar && titleBar->rect().contains(pos)) {
QWidget *child = titleBar->childAt(pos);
if (!child) {
*result = HTCAPTION;

View File

@@ -26,7 +26,7 @@ FramelessWidget2::FramelessWidget2(QObject *parent) : QObject(parent)
bool FramelessWidget2::eventFilter(QObject *watched, QEvent *event)
{
if (widget != 0 && watched == widget) {
if (widget && watched == widget) {
if (event->type() == QEvent::WindowStateChange) {
//解决mac系统上无边框最小化失效的bug
#ifdef Q_OS_MACOS

View File

@@ -17,7 +17,7 @@ LunarCalendarWidget::LunarCalendarWidget(QWidget *parent) : QWidget(parent)
if (!fontDb.families().contains("FontAwesome")) {
int fontId = fontDb.addApplicationFont(":/font/fontawesome-webfont.ttf");
QStringList fontName = fontDb.applicationFontFamilies(fontId);
if (fontName.count() == 0) {
if (fontName.size() == 0) {
qDebug() << "load fontawesome-webfont.ttf error";
}
}

View File

@@ -71,7 +71,7 @@ void MaskWidget::setBgColor(const QColor &bgColor)
void MaskWidget::showEvent(QShowEvent *)
{
if (mainWidget != 0) {
if (mainWidget) {
this->setGeometry(mainWidget->geometry());
}
}
@@ -91,7 +91,7 @@ bool MaskWidget::eventFilter(QObject *obj, QEvent *event)
}
} else if (event->type() == QEvent::WindowActivate) {
//当主窗体激活时,同时激活遮罩层
if (mainWidget != 0) {
if (mainWidget) {
if (obj->objectName() == mainWidget->objectName()) {
if (this->isVisible()) {
this->activateWindow();

View File

@@ -13,7 +13,7 @@ MoveWidget::MoveWidget(QObject *parent) : QObject(parent)
bool MoveWidget::eventFilter(QObject *watched, QEvent *event)
{
if (widget != 0 && watched == widget) {
if (widget && watched == widget) {
QMouseEvent *mouseEvent = (QMouseEvent *)event;
if (mouseEvent->type() == QEvent::MouseButtonPress) {
//如果限定了只能鼠标左键拖动则判断当前是否是鼠标左键
@@ -38,7 +38,7 @@ bool MoveWidget::eventFilter(QObject *watched, QEvent *event)
bool xyOut = (x + widget->width() < offset || y + widget->height() < offset);
bool whOut = false;
QWidget *w = (QWidget *)widget->parent();
if (w != 0) {
if (w) {
whOut = (w->width() - x < offset || w->height() - y < offset);
}
if (xyOut || whOut) {
@@ -71,4 +71,4 @@ void MoveWidget::setWidget(QWidget *widget)
this->widget = widget;
this->widget->installEventFilter(this);
}
}
}