.h
.cpp
.h
#ifndef INQUIREPAGE_H
#define INQUIREPAGE_H
#include <QWidget>
namespace Ui {
class InquirePage;
}
class InquirePage : public QWidget
{
Q_OBJECT
public:
explicit InquirePage(QWidget *parent = 0);
~InquirePage();
void btn_init();
private slots:
void slot_btn_cli();
private:
Ui::InquirePage *ui;
};
#endif // INQUIREPAGE_H
.cpp
#include "inquirepage.h"
#include "ui_inquirepage.h"
#include <QDebug>
InquirePage::InquirePage(QWidget *parent) :
QWidget(parent),
ui(new Ui::InquirePage)
{
ui->setupUi(this);
btn_init();
}
InquirePage::~InquirePage()
{
delete ui;
}
void InquirePage::btn_init()
{
QList<QPushButton *> list = findChildren<QPushButton *>();
for(int i = 0; i < list.length(); i++) {
qDebug() << list[i]->objectName();
connect(list[i], &QPushButton::clicked, this, &InquirePage::slot_btn_cli);
}
}
void InquirePage::slot_btn_cli()
{
QPushButton *btn = qobject_cast<QPushButton *>(sender());
if(btn == ui->btnInquire) {
} else if(btn == ui->btnClear) {
}
}