效果图
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200525144205334.png)
源代码
#include "NavButton.h"
NavButton::NavButton(QWidget *parent) : QWidget(parent)
{
m_buttons.setExclusive(true);
connect(&m_buttons, QOverload<int>::of(&QButtonGroup::buttonClicked),
[=](int id){
emit this->buttonClicked(id);});
connect(&m_buttons, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
[=](QAbstractButton *button){
emit this->buttonClicked(button);});
}
void NavButton::InitWidget()
{
if ( m_HBoxLayout != nullptr)
return;
InitStyleSheet();
m_HBoxLayout = new QHBoxLayout(this);
foreach (QAbstractButton *button, m_buttons.buttons()) {
button->setMinimumHeight