资源简介
C++仿360新界面源代码

代码片段和文件信息
#include “clabel.h“
//Download by http://www.codefans.net
CLabel::CLabel(QWidget *parent) :
QWidget(parent)
{
initVariable();
initSetupUi();
}
CLabel::~CLabel()
{
delete m_pLabelIcon;
delete m_pLabelText;
delete m_pHLayout;
}
void CLabel::setPixmap(const QPixmap &pixmap)
{
m_pLabelIcon->setPixmap(pixmap.scaled(QSize(30 30) Qt::KeepAspectRatio Qt::SmoothTransformation));
}
void CLabel::setText(const QString &text)
{
m_pLabelText->setText(text);
}
void CLabel::setMouseEnterFlag(bool flag)
{
m_mouseEnterFlag = flag;
this->update();
}
void CLabel::setMousePressFlag(bool flag)
{
m_mousePressFlag = flag;
this->update();
}
void CLabel::enterEvent(QEvent *e)
{
if (!getMousePressFlag())
{
setMouseEnterFlag(true);
}
this->setCursor(Qt::PointingHandCursor);
}
void CLabel::leaveEvent(QEvent *e)
{
setMouseEnterFlag(false);
}
void CLabel::mousePressEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton)
{
setMousePressFlag(true);
emit signalLabelPress(this);
}
}
void CLabel::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
if (getMouseEnterFlag())
{
paintWidget(50 &painter);
}
else if (getMousePressFlag())
{
paintWidget(80 &painter);
}
QWidget::paintEvent(e);
}
void CLabel::initVariable()
{
setMouseEnterFlag(false);
setMousePressFlag(false);
}
void CLabel::initSetupUi()
{
createframe();
createWidget();
createLayout();
}
void CLabel::createframe()
{
this->setstyleSheet(“QWidget {background:transparent;border:0px;color:white;font-weight:bold;font-size:16px;}“);
}
void CLabel::createWidget()
{
m_pLabelIcon = new QLabel(this);
m_pLabelText = new QLabel(this);
}
void CLabel::createLayout()
{
m_pHLayout = new QHBoxLayout;
m_pHLayout->setSpacing(6);
m_pHLayout->setContentsMargins(QMargins(5 0 5 0));
m_pHLayout->addWidget(m_pLabelIcon);
m_pHLayout->addWidget(m_pLabelText);
this->setLayout(m_pHLayout);
}
void CLabel::paintWidget(int transparency QPainter *device)
{
QPen pen(Qt::NoBrush 1);
device->setPen(pen);
QLinearGradient linear(this->rect().topLeft() this->rect().bottomLeft());
linear.setColorAt(0 QColor(255 255 255 transparency));
QBrush brush(linear);
device->setBrush(brush);
device->drawRoundedRect(this->rect() 2 2);
}
inline bool CLabel::getMouseEnterFlag()
{
return m_mouseEnterFlag;
}
inline bool CLabel::getMousePressFlag()
{
return m_mousePressFlag;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-09-18 18:28 C++仿360新界面源代码\
文件 448 2012-05-20 22:07 C++仿360新界面源代码\360Preview.pro
文件 18938 2012-05-22 14:38 C++仿360新界面源代码\360Preview.pro.user
文件 2704 2013-05-22 11:07 C++仿360新界面源代码\clabel.cpp
文件 1031 2012-05-18 22:36 C++仿360新界面源代码\clabel.h
文件 347 2012-05-21 21:31 C++仿360新界面源代码\common.h
目录 0 2014-09-18 01:40 C++仿360新界面源代码\images\
文件 22486 2012-05-17 21:47 C++仿360新界面源代码\images\360Preview.ico
文件 44 2012-05-17 21:47 C++仿360新界面源代码\images\360preview.rc
文件 15971 2012-05-17 21:47 C++仿360新界面源代码\images\bg_bottom.png
文件 479 2012-05-17 21:47 C++仿360新界面源代码\images\bg_briangle.png
文件 7029 2012-05-17 21:47 C++仿360新界面源代码\images\bg_top.png
文件 2425 2012-05-17 21:47 C++仿360新界面源代码\images\btn_0.png
文件 2488 2012-05-17 21:47 C++仿360新界面源代码\images\btn_1.png
文件 3726 2012-05-17 21:47 C++仿360新界面源代码\images\btn_2.png
文件 2857 2012-05-17 21:47 C++仿360新界面源代码\images\btn_3.png
文件 1756 2012-05-17 21:47 C++仿360新界面源代码\images\btn_close.png
文件 13260 2012-05-17 21:47 C++仿360新界面源代码\images\btn_open.png
文件 13101 2012-05-17 21:47 C++仿360新界面源代码\images\btn_use.png
文件 59044 2012-05-17 21:47 C++仿360新界面源代码\images\desktop_0.jpg
文件 34811 2012-05-17 21:47 C++仿360新界面源代码\images\desktop_1.jpg
文件 41339 2012-05-17 21:47 C++仿360新界面源代码\images\desktop_2.jpg
文件 40093 2012-05-17 21:47 C++仿360新界面源代码\images\desktop_3.jpg
文件 569 2012-05-20 21:20 C++仿360新界面源代码\images\images.qrc
文件 402 2012-05-22 14:38 C++仿360新界面源代码\main.cpp
文件 11825 2013-05-22 11:08 C++仿360新界面源代码\preview360.cpp
文件 1630 2012-05-21 21:29 C++仿360新界面源代码\preview360.h
文件 54 2014-09-17 20:10 C++仿360新界面源代码\大量源码IT资源免费下载.txt
相关资源
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
- VC++基于OpenGL模拟的一个3维空间模型
评论
共有 条评论