QT传递带槽参数的函数

时间:2017-03-27 04:43:52

标签: c++ qt signals-slots

所以当我按下我创建的按钮时,我想调用函数: QPushButton *pb = new QPushButton; 我想打电话的功能是:Engine::gauss(QLineEdit *&line, QLineEdit *&results, int sizeMatters)。所以问题是我所有这些参数都在另一个槽中,在on_button_clicked函数中是准确的:

   void MainWindow::on_pushButton_clicked()
{
    Result x;
    int sizeMatters;
    sizeMatters=ui->le_size->text().toInt();

    int c = ui->grid->count();
    if(c!=0){
        for(int m = 0; m < c; m++){
            ui->grid->itemAt(m)->widget()->close();
        }

    }

    c = ui->grid_results->count();
    if(c!=0){
        for(int f = 0; f < c; f++){
            ui->grid_results->itemAt(f)->widget()->close();
        }
    }
    ui->le_size->setMaxLength(2);

    QLineEdit *line = new QLineEdit[sizeMatters*sizeMatters];
    QLabel *label = new QLabel[sizeMatters];
    QLineEdit *results = new QLineEdit[sizeMatters];
    QLineEdit *finals = new QLineEdit[sizeMatters];

    int w = 0;
    for(int j = 0; j<sizeMatters; j++){
        for(int i = 0; i<sizeMatters; i++){
            ui->grid->addWidget(&line[w],j+1,i+1);
            w++;

        }
        label[j].setText("=");
        ui->grid->addWidget(&label[j],j+1,sizeMatters+1);
        ui->grid->addWidget(&results[j],j+1,sizeMatters+2);

    }


    for(int j = 0; j<sizeMatters; j++){
        ui->grid_results->addWidget(&finals[j],1,j+1);
    }
    QPushButton *pb = new QPushButton;
    if(c==0){

    ui->verticalLayout->addWidget(pb);
  }



    for(int p=0;p<sizeMatters;p++){
        QString liczba = QString::number(x.wyniki[p]);

        finals[p].setText(liczba);
    }



}

所以我想调用engine.cpp中的高斯函数,并且当点击“pb”按钮时它是Engine类的一部分。我怎样才能做到这一点?

0 个答案:

没有答案