48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
//
|
|
// Created by HW on 2023/07/26.
|
|
//
|
|
|
|
// You may need to build the project (run Qt uic code generator) to get "ui_NavBar.h" resolved
|
|
|
|
#include "navbar.h"
|
|
#include "ui_NavBar.h"
|
|
|
|
|
|
NavBar::NavBar(QList<ButtonStruct *> &buttonNames,QWidget *parent) :
|
|
QWidget(parent), ui(new Ui::NavBar) {
|
|
ui->setupUi(this);
|
|
layout=new QHBoxLayout();
|
|
layout->setMargin(0);
|
|
this->setMinimumHeight(48);
|
|
this->setMaximumHeight(150);
|
|
for(auto buttonName : buttonNames){
|
|
MyButton *button=new MyButton(buttonName->logo,buttonName->text,height(),height());
|
|
//QSizePolicy sizePolicy(QSizePolicy::Policy::Maximum, QSizePolicy::QSizePolicy::Maximum);
|
|
//button->setSizePolicy(sizePolicy);
|
|
layout->addWidget(button);
|
|
buttons<<button;
|
|
}
|
|
layout->setAlignment(Qt::AlignHCenter);
|
|
|
|
this->setLayout(layout);
|
|
|
|
}
|
|
|
|
NavBar::~NavBar() {
|
|
for(auto button : buttons){
|
|
delete button;
|
|
}
|
|
delete layout;
|
|
delete ui;
|
|
}
|
|
|
|
void NavBar::paintEvent(QPaintEvent *event) {
|
|
QWidget::paintEvent(event);
|
|
|
|
QPainter painter(this);
|
|
painter.setRenderHint(QPainter::Antialiasing);
|
|
|
|
QRectF rect(0, 0, this->width(), this->height());
|
|
painter.fillRect(rect, QColor("#333332"));
|
|
}
|