资源简介
竖形通用界面
简洁通用
代码片段和文件信息
#include “appinit.h“
#include “qmutex.h“
#include “qapplication.h“
#include “qevent.h“
#include “qwidget.h“
AppInit *AppInit::self = 0;
AppInit *AppInit::Instance()
{
if (!self) {
QMutex mutex;
QMutexLocker locker(&mutex);
if (!self) {
self = new AppInit;
}
}
return self;
}
AppInit::AppInit(Qobject *parent) : Qobject(parent)
{
}
bool AppInit::eventFilter(Qobject *obj QEvent *evt)
{
QWidget *w = (QWidget *)obj;
if (!w->property(“canMove“).toBool()) {
return Qobject::eventFilter(obj evt);
}
static QPoint mousePoint;
static bool mousePressed = false;
QMouseEvent *event = static_cast(evt);
if (event->type() == QEvent::MouseButtonPress) {
if (event->button() == Qt::LeftButton) {
mousePressed = true;
mousePoint = event->globalPos() - w->pos();
return true;
}
} else if (event->type() == QEvent::MouseButtonRelease) {
mousePressed = false;
return true;
} else if (event->type() == QEvent::MouseMove) {
if (mousePressed && (event->buttons() && Qt::LeftButton)) {
w->move(event->globalPos() - mousePoint);
return true;
}
}
return Qobject::eventFilter(obj evt);
}
void AppInit::start()
{
qApp->installEventFilter(this);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-18 11:55 uidemo12\
文件 1429 2017-09-16 14:07 uidemo12\appinit.cpp
文件 384 2017-09-16 14:04 uidemo12\appinit.h
文件 9598 2018-01-10 16:42 uidemo12\icon
文件 2642 2018-01-10 16:45 uidemo12\icon
目录 0 2018-04-18 22:35 uidemo12\image\
文件 165548 2017-04-09 17:13 uidemo12\image\fontawesome-webfont.ttf
文件 750 2017-06-14 09:16 uidemo12\main.cpp
文件 113 2017-06-07 09:41 uidemo12\main.qrc
文件 3024 2017-09-24 18:56 uidemo12\uidemo12.cpp
文件 437 2017-06-14 09:24 uidemo12\uidemo12.h
文件 711 2017-09-16 13:54 uidemo12\uidemo12.pro
文件 8549 2017-06-14 09:32 uidemo12\uidemo12.ui
评论
共有 条评论