1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-03-16 11:09:50 +08:00
Qt-Advanced-Docking-System/AdvancedDockingSystemDemo/src/icontitlewidget.cpp

36 lines
873 B
C++
Raw Normal View History

2015-12-09 19:21:38 +08:00
#include "icontitlewidget.h"
#include <QIcon>
#include <QString>
#include <QBoxLayout>
#include <QLabel>
#include <QStyle>
IconTitleWidget::IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent) :
QFrame(parent)
{
auto l = new QBoxLayout(QBoxLayout::LeftToRight);
l->setContentsMargins(0, 0, 0, 0);
setLayout(l);
// Icon label
2015-12-09 19:21:38 +08:00
if (icon.isNull())
{
// auto titleIcon = new QLabel();
// titleIcon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxInformation).pixmap(16, 16));
// l->addWidget(titleIcon);
2015-12-09 19:21:38 +08:00
}
else
{
auto titleIcon = new QLabel();
2015-12-09 19:21:38 +08:00
titleIcon->setPixmap(icon.pixmap(16, 16));
l->addWidget(titleIcon);
2015-12-09 19:21:38 +08:00
}
// Title label
2015-12-09 19:21:38 +08:00
auto titleText = new QLabel(title);
auto titleFont = titleText->font();
titleFont.setBold(true);
titleText->setFont(titleFont);
l->addWidget(titleText, 1);
}