資源簡介
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
評論
共有 條評論