1
votes

Im a student programmer using Qt to develop a GUI for work and I have ran into a problem using the QTableWidget. I have a spreadsheet made from this widget that takes various values as user input. I have a QLineedit field outside of this spreadsheet that needs to display a the sum of any values in the 9th column. In this case i thought it would be best to use the cellchanged signal to add the 9th column together and show set the linedit field to the sum of all these cells. My problem is when I go to execute my application I recieve the following application output and this part in my GUI doesnt work:

> Object::connect: No such slot InjectionDialog::addWeightSum(int,int)
> Object::connect:  (sender name:   'tableWidgetInjectionLocations')
> Object::connect:  (receiver name: 'InjectionDialog')

I have made sure many times that this slot does in fact exist and is called correctly to the best of my knowledge. However I am a student and maybe I am not right and now I'm here.

my InjectionDialog.h contains the following slots;

private slots:
    void accepted_Clicked();
    void cancel_Clicked();
    void useFluidiFileRdoBtn_Clicked();
    void useFluidSpecifiedValuesRdoBtn_Clicked();
    void useParticleiFileRdoBtn_Clicked();
    void useParticleSpecifiedValuesRdoBtn_Clicked();
    void particleInjectionRdoBtn_Clicked();
    void liquidDropletsRdoBtn_Clicked();
    void addWeightSum(int &row, int &col);

my injectiondialog.cpp contains the following.

InjectionDialog::InjectionDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::InjectionDialog)
{
    ui->setupUi(this);
    connect(ui->pushButtonAccept, SIGNAL(clicked()), this, SLOT(accepted_Clicked()));
    connect(ui->pushButtonCancel, SIGNAL(clicked()), this, SLOT(cancel_Clicked()));
    connect(ui->radioButtonUseiFileFluidInjection, SIGNAL(clicked()), this, SLOT(useFluidiFileRdoBtn_Clicked()));
    connect(ui->radioButtonUseSpecifiedValuesFluidInjection, SIGNAL(clicked()), this, SLOT(useFluidSpecifiedValuesRdoBtn_Clicked()));
    connect(ui->radioButtonUseiFileParticleInjection, SIGNAL(clicked()), this, SLOT(useParticleiFileRdoBtn_Clicked()));
    connect(ui->radioButtonUseSpecifiedValuesParitcleInjection, SIGNAL(clicked()), this, SLOT(useParticleSpecifiedValuesRdoBtn_Clicked()));
    connect(ui->tableWidgetInjectionLocations, SIGNAL(cellChanged(int,int)), this, SLOT(addWeightSum(int &row, int &col)));

My injection dialog also include my function for adding this column; it is as follows:

void InjectionDialog::addWeightSum(int &row, int &col)
{
    double weightSum;
    double totalWeightSum;
    QString tempstr;
    bool check;
    if(col == 9)
    {
        for (int i = 0; i < ui->tableWidgetInjectionLocations->rowCount(); i++)
        {
            if (ui->tableWidgetInjectionLocations->item(i,9)->text() != "")
            {
                tempstr = ui->tableWidgetInjectionLocations->item(i,9)->text();
                weightSum = tempstr.toDouble(&check);
                if(check == false)
                {
                    ui->lineEditWeightSum->setText("Error");
                    break;
                }
                else
                {
                    totalWeightSum += weightSum;
                }
            }
        }
        ui->lineEditWeightSum->clear();
        tempstr.append(QString("%1").arg(totalWeightSum));
        ui->lineEditWeightSum->setText(tempstr);
    }

}

This issue could be caused by something simple that I'm just not seeing. I appreciate any help that you can offer. Please only leave constructive feed back as I am only interested in improving and accomplishing my goals here. In that regard I appreciate all attempts to assist and thank you for reading this.

1
I am not that experienced at Qt but maybe the problem is the references. Did you try to rewrite addWeightSum to get the arguments passed by value instead of reference? - Nobody moving away from SE
Indeed I did, same issue.. which makes me think that the application doesn't even get that far. because I should have an error with one of those parameter methods - Wylie Coyote SG.
Did you clean the project? Maybe your build environment is somehow polluted by old binaries that introduce errors. Although this is highly unlikely. - Nobody moving away from SE
I agree with Nobody. Sometimes you if don't rebuild from scratch Qt can throw some unexpected surprises. - Neox
Passing arguments by reference in a slot is useless when using connect anyway... - UmNyobe

1 Answers

2
votes

You signal slot signatures differ. In your declaration of void addWeightSum(int &row, int &col); you have put references. Remove them. void addWeightSum(int row, int col);