// // Created by HW on 2023/07/26. // // You may need to build the project (run Qt uic code generator) to get "ui_MainWindowLagout.h" resolved #include "mainwindowlayout.h" #include "ui_MainWindowLayout.h" MainWindowLayout::MainWindowLayout(QWidget *parent) : QWidget(parent), ui(new Ui::MainWindowLayout) { ui->setupUi(this); layout=new QVBoxLayout(this); buttons=new ButtonStruct[4]; buttons[0].text="主页"; buttons[0].logo=".\\images\\home.png"; buttons[0].index=0; buttons[1].text="我的网址"; buttons[1].logo=".\\images\\address.png"; buttons[1].index=1; buttons[2].text="我的资产"; buttons[2].logo=".\\images\\money.png"; buttons[2].index=2; buttons[3].text="个人中心"; buttons[3].logo=".\\images\\personalcenter.png"; buttons[3].index=3; for(auto i=0;i<4;i++) { list << &buttons[i]; } this->setLayout(nullptr); navBar=new NavBar(list,this); mainScreen=new MainScreen(); //QSizePolicy sizePolicy(QSizePolicy::Policy::Fixed, QSizePolicy::QSizePolicy::Fixed); //navBar->setSizePolicy(sizePolicy); layout->setMargin(0); layout->addWidget(navBar,1); layout->addWidget(mainScreen,4); setLayout(layout); } MainWindowLayout::~MainWindowLayout() { delete[] list[0]; delete navBar; //delete layout; delete ui; } void MainWindowLayout::resizeEvent(QResizeEvent *event) { QWidget::resizeEvent(event); navBar->resize(navBar->width(),height()/5); //layout->setAlignment(Qt::AlignmentFlag::AlignHCenter); } /*void MainWindowLayout::paintEvent(QPaintEvent *event) { QWidget::paintEvent(event); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); QRectF rect(0, 0, this->width(), this->height()/5); painter.fillRect(rect, QColor("#333332")); }*/