资源简介
鼠标取色器,取值取色值源码,鼠标全屏幕取点取色。switch (e->type()) {
case QEvent::MouseMove:
MouseMoveColorPicker((QMouseEvent *)e);
break;
case QEvent::MouseButtonPress:
m_wid->setCursor(Qt::CrossCursor);
break;
case QEvent::MouseButtonRelease:
m_wid->setCursor(Qt::ArrowCursor);
break;
default:
break;
}
return QObject::eventFilter(obj, e);
代码片段和文件信息
#include “ColorPickerHandler.h“
#include
#include
#include
#include
#include
#include
#include
#include
ColorPickerHandler::ColorPickerHandler(QWidget* wid Qobject *parent)
{
Q_UNUSED(parent);
m_wid = wid;
}
bool ColorPickerHandler::eventFilter(Qobject *obj QEvent *e)
{
switch (e->type()) {
case QEvent::MouseMove:
MouseMoveColorPicker((QMouseEvent *)e);
break;
case QEvent::MouseButtonPress:
m_wid->setCursor(Qt::CrossCursor);
break;
case QEvent::MouseButtonRelease:
m_wid->setCursor(Qt::ArrowCursor);
break;
default:
break;
}
return Qobject::eventFilter(obj e);
}
void ColorPickerHandler::MouseMoveColorPicker(QMouseEvent *e)
{
Q_UNUSED(e);
QScreen* screen = QGuiApplication::primaryScreen();
QPoint point = QCursor::pos();
QPixmap pix = screen->grabWindow(QApplication::desktop()->winId()point.x()point.y()11);
QImage image = pix.toImage();
QColor color = image.pixelColor(00);
// QString strR = QString::number(color.red() 16);
// QString strG = QString::number(color.green() 16);
// QString strB = QString::number(color.blue() 16);
// QString strRgb = QString(“%1%2%3“).arg(QString(“%1“).arg(strR.size() == 1 ? strR.prepend(“0“) : strR)
// QString(“%1“).arg(strG.size() == 1 ? strG.prepend(“0“) : strG)
// QString(“%1“).arg(strB.size() == 1 ? strB.prepend(“0“) : strB));
// QString styleSheet = QString(“background-color:#%1;“).arg(strRgb);
// m_wid->setstyleSheet(styleSheet);
QPalette pal(m_wid->palette());
pal.setColor(QPalette::Backgroundcolor);
m_wid->setAutoFillBackground(true);
m_wid->setPalette(pal);
emit ColorChanged(&color);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 484 2017-10-25 17:03 ColorPicker\ColorPicker.pro
文件 23589 2017-10-27 18:03 ColorPicker\ColorPicker.pro.user
文件 43504 2017-10-25 17:03 ColorPicker\ColorPicker.pro.user.31aa207
文件 1905 2017-10-25 17:03 ColorPicker\ColorPickerHandler.cpp
文件 538 2017-10-25 17:03 ColorPicker\ColorPickerHandler.h
文件 420 2017-10-25 17:03 ColorPicker\main.cpp
文件 4286 2017-10-25 17:03 ColorPicker\snow.ico
文件 3524 2017-10-27 18:01 ColorPicker\widget.cpp
文件 755 2017-10-25 17:03 ColorPicker\widget.h
文件 3947 2017-10-25 17:03 ColorPicker\widget.ui
目录 0 2017-10-27 18:03 ColorPicker
----------- --------- ---------- ----- ----
82952 11
- 上一篇:wifi字典百度云链接.txt
- 下一篇:pwdump7.rar
评论
共有 条评论