How to link push button and a new window by coding using QT? : First of all, I created about 20 push buttons using for loop. And named them using if else loop. Now, I want to connect each push buttons with the new dialog box. If I had used the design mode of QT, it would show me the name of the button when I press connect(ui->pushButton_0, SIGNAl(released()), SLOT(digit_pressed()) something like this. But, I don't know the name of the pushbutton I made as the for and if else loop made it. The connect(ui-> .......) also doesn't show any predictions. How can I link these push buttons and a new dialog box?


Here is my code:
**mainwindow.h**

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    
    private slots:
        void on_pushButton_clicked();
    
    };
    
    #endif // MAINWINDOW_H

**mainwindow.cpp**

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QPushButton>
    #include <QVBoxLayout>
    #include "amputation.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        connect(ui->)
    
    
    
        QPixmap pix("/home/skanda/Desktop/D4564.png");
        ui->label_2->setPixmap(pix);
        setWindowTitle("First Aid");
    
        QVBoxLayout *lay = new QVBoxLayout();
        int i;
        for(i=0;i<25;i++)
        {
            if(i==0){
                 QPushButton *button = new QPushButton("Amputation");
                 lay->addWidget(button);
            }
            else if(i==1){
                QPushButton *button = new QPushButton("Asthama");
                lay->addWidget(button);
    
            }
            else if(i==2){
                QPushButton *button = new QPushButton("Bleeding");
                lay->addWidget(button);
    
            }
            else if(i==3){
                QPushButton *button = new QPushButton("Burns");
                lay->addWidget(button);
    
            }
            else if(i==4){
                QPushButton *button = new QPushButton("Chest Pain");
                lay->addWidget(button);
    
            }
            else if(i==5){
                QPushButton *button = new QPushButton("Diarrhoea");
                lay->addWidget(button);
    
            }
            else if(i==6){
                QPushButton *button = new QPushButton("Drowning");
                lay->addWidget(button);
    
            }
            else if(i==7){
                QPushButton *button = new QPushButton("Epilepsy");
                lay->addWidget(button);
    
            }
            else if(i==8){
                QPushButton *button = new QPushButton("Fainting");
                lay->addWidget(button);
    
            }
            else if(i==9){
                QPushButton *button = new QPushButton("Fever");
                lay->addWidget(button);
    
            }
            else if(i==10){
                QPushButton *button = new QPushButton("Food Poisoning");
                lay->addWidget(button);
    
            }
            else if(i==11){
                QPushButton *button = new QPushButton("Fracture");
                lay->addWidget(button);
    
            }
            else if(i==12){
                QPushButton *button = new QPushButton("Head Injury");
                lay->addWidget(button);
    
            }
            else if(i==13){
                QPushButton *button = new QPushButton("Muscle Strain");
                lay->addWidget(button);
    
            }
            else if(i==14){
                QPushButton *button = new QPushButton("No breathing");
                lay->addWidget(button);
    
            }
            else if(i==15){
                QPushButton *button = new QPushButton("Nose bleed");
                lay->addWidget(button);
    
            }
            else if(i==16){
                QPushButton *button = new QPushButton("Poisoning");
                lay->addWidget(button);
    
            }
            else if(i==17){
                QPushButton *button = new QPushButton("Snake Bites");
                lay->addWidget(button);
    
            }
            else if(i==18){
                QPushButton *button = new QPushButton("Stroke");
                lay->addWidget(button);
    
            }
            else if(i==19) {
                QPushButton *button = new QPushButton("Sun Burn");
                lay->addWidget(button);
    
            }
            else if(i==20) {
                QPushButton *button = new QPushButton("Testicle Pain");
                lay->addWidget(button);
    
            }
            else if(i==21) {
                QPushButton *button = new QPushButton("Ulcer");
                lay->addWidget(button);
    
            }
            else if(i==22) {
                QPushButton *button = new QPushButton("Child delievery");
                lay->addWidget(button);
    
            }
            else if(i==23) {
                QPushButton *button = new QPushButton("Heart Attack");
                lay->addWidget(button);
    
            }
            else {
                QPushButton *button = new QPushButton("Gastric");
                lay->addWidget(button);
    
            }
        }
    
    
        ui->scrollContents->setLayout(lay);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::on_pushButton_clicked(){
        Amputation amp;
        amp.setModal(true);
        amp.show();
    }

**In these codes, I have tried my luck by creating on_pushButton_clicked() function. But, it was just a try. **












