You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.6 KiB
C++
57 lines
1.6 KiB
C++
#include "FITKLockerButton.h"
|
|
#include <QLabel>
|
|
#include <QHBoxLayout>
|
|
#include <QPixmap>
|
|
|
|
namespace Comp
|
|
{
|
|
FITKLockerButton::FITKLockerButton(QWidget* parent) :
|
|
QPushButton(parent)
|
|
{
|
|
this->setObjectName("DrawerWidgetButton");
|
|
//标题label初始化
|
|
m_textLabel = new QLabel(this);
|
|
m_textLabel->setText("DrawerWidgetLabel");
|
|
m_textLabel->setObjectName("DrawerWidgetLabel");
|
|
//图片label初始化
|
|
m_iconLabel = new QLabel(this);
|
|
m_iconLabel->setText("DrawerWidgetIcon");
|
|
initialize();
|
|
}
|
|
|
|
FITKLockerButton::~FITKLockerButton()
|
|
{
|
|
if (m_textLabel != nullptr) delete m_textLabel;
|
|
if (m_iconLabel != nullptr) delete m_iconLabel;
|
|
}
|
|
|
|
void FITKLockerButton::setText(const QString& text)
|
|
{
|
|
//设置标题
|
|
m_textLabel->setText(text);
|
|
}
|
|
|
|
void FITKLockerButton::setImage(const QPixmap& image)
|
|
{
|
|
//设置图标
|
|
m_iconLabel->setPixmap(image);
|
|
}
|
|
|
|
void FITKLockerButton::initialize()
|
|
{
|
|
m_iconLabel->setFixedWidth(16);
|
|
m_iconLabel->setFixedHeight(16);
|
|
m_iconLabel->setScaledContents(true);
|
|
m_textLabel->setText(tr("Page"));
|
|
|
|
//界面布局添加
|
|
QHBoxLayout* hLayout = new QHBoxLayout;
|
|
hLayout->setObjectName("LockerButtonHBoxLayout");
|
|
hLayout->addWidget(m_iconLabel);
|
|
hLayout->addWidget(m_textLabel);
|
|
hLayout->setMargin(0);
|
|
hLayout->setSpacing(6);
|
|
hLayout->setContentsMargins(10, 0, 0, 0);
|
|
this->setLayout(hLayout);
|
|
}
|
|
} |