资源简介
Qt个性化系统的实现,模仿了电脑管家的系统托盘,因为图标没有找到,所以图标不是很像。但是基本很相似。
代码片段和文件信息
#include “computermanager.h“
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “myswitchbutton.h“
ComputerManager::ComputerManager(Qobject *parent) :
QSystemTrayIcon(parent)
{
this->initAction();
this->initTopAction();
this->initMidAction();
this->initBottomAction();
this->addActions();
this->initConnect();
this->translateActions();
}
void ComputerManager::translateActions()
{
m_tbnOpenSteward->setText(tr(“Open“));
m_tbnHome->setText(tr(“check“));
m_tbnAntiVirus->setText(tr(“AntiVi“));
m_tbnCleanRubbish->setText(tr(“Clean“));
m_tbnComputerSpeed->setText(tr(“Comput“));
m_tbnComputerClinic->setText(tr(“Clinic“));
}
bool ComputerManager::eventFilter(Qobject *obj QEvent *event)
{
if (obj == m_topWidget && event->type() == QEvent::Paint)
{
QPainter painter(m_topWidget);
painter.setPen(Qt::NoPen);
painter.setBrush(QColor(42120192));
painter.drawRect(m_topWidget->rect());
}
return QSystemTrayIcon::eventFilter(objevent);
}
void ComputerManager::initTopAction()
{
//顶层菜单项初始化
m_topWidget = new QWidget();
m_topWidgetAction = new QWidgetAction(m_trayMenu);
m_topLabelIcon = new QLabel();
m_topLabelIcon->setPixmap(QPixmap(“:/image/topicon.png“));
m_topLabelIcon->setFixedSize(3030);
m_topLabel = new QLabel(tr(“Comuter Manager now protected you!“));
m_topLabel->setobjectName(QString(“WhiteLabel“));
m_topLabel->setFont(QFont(“Times“ 11));
QHBoxLayout* m_topLayout = new QHBoxLayout();
m_topLayout->addWidget(m_topLabelIcon);
m_topLayout->addWidget(m_topLabel1Qt::AlignHCenter | Qt::AlignVCenter);
m_topLayout->setContentsMargins(0000);
m_topWidget->setLayout(m_topLayout);
m_topWidget->setMinimumHeight(70);
m_topWidget->installEventFilter(this);
m_topWidgetAction->setDefaultWidget(m_topWidget);
m_topQQWidget = new QWidget();
m_topQQWidgetAction = new QWidgetAction(m_trayMenu);
m_QQInfoBtn = new QLabel(tr(“qq infor safety\n“)+
tr(“reinforce more secure“));
m_QQInfoBtn->setCursor(Qt::PointingHandCursor);
m_labelIcon = new QLabel();
m_labelIcon->setPixmap(QPixmap(“:/image/icon.png“));
m_labelIcon->setFixedSize(5050);
QHBoxLayout* m_topQQLayout = new QHBoxLayout();
m_topQQLayout->addWidget(m_labelIcon);
m_topQQLayout->addWidget(m_QQInfoBtn);
m_topQQLayout->setContentsMargins(0000);
m_topQQWidget->setLayout(m_topQQLayout);
m_topQQWidget->setMinimumHeight(70);
m_topQQWidget->installEventFilter(this);
m_topQQWidgetAction->setDefaultWidget(m_topQQWidget);
m_topTbnWidget = new QWidget(
- 上一篇:squashfs-tools.zip
- 下一篇:SSL加密https通信源码
评论
共有 条评论