1 Star 0 Fork 3

OPMichael/QTLauncher

forked from murphy/QTLauncher 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
basewidget.cpp 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
murphy 提交于 2017-06-21 00:46 . init
#include "basewidget.h"
#include "toolbar.h"
#include <QVBoxLayout>
#include <QPaintEvent>
#include <QPainter>
namespace ui {
BaseWidget::BaseWidget(QWidget *parent, Qt::WindowFlags flags)
//:QWidget(parent)
:QWidget(parent, flags)
{
createLayout();
}
BaseWidget::BaseWidget(QPixmap background, QWidget *parent, Qt::WindowFlags flags)
//:QWidget(parent)
:QWidget(parent, flags)
,mBackgroundPixmap(background)
{
createLayout();
}
BaseWidget::~BaseWidget()
{
delete mCentralLayout;
delete mBar;
}
void BaseWidget::createLayout()
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mCentralLayout = new QVBoxLayout;
mBar = new ToolBar;
//mainLayout->addStretch(1);
mainLayout->addLayout(mCentralLayout);
//mainLayout->addStretch(1);
mainLayout->addWidget(mBar);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
connect(mBar, SIGNAL(backAction()), SLOT(onToolBackClicked()));
connect(mBar, SIGNAL(homeAction()), SLOT(onToolHomeClicked()));
}
void BaseWidget::paintEvent(QPaintEvent *event)
{
if (!mBackgroundPixmap.isNull()){
QPainter painter(this);
painter.drawPixmap(0, 0, mBackgroundPixmap.scaled(size()));
}
QWidget::paintEvent(event);
}
void BaseWidget::onToolBackClicked()
{
emit quit();
close();
}
void BaseWidget::onToolHomeClicked()
{
emit quit();
close();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/michaelheaven/qtlauncher.git
git@gitee.com:michaelheaven/qtlauncher.git
michaelheaven
qtlauncher
QTLauncher
master

搜索帮助