In the following code the compiler says that the variable "currentRow" is unused in "on_pushButton_2_clicked()" and not declared in "on_pushButton_clicked()". I've tried declaring "int currentRow" in every place and in every way I can think of and nothing works. Seems like a trivial issue, but I'm stumped.
void Dialog::on_pushButton_2_clicked()
{
// declare and set variables
QMessageBox::information(this,
"Settings",
"Setting Row and Column");
int currentRow = 3;
int currentCol = 5;
}
void Dialog::on_pushButton_clicked()
{
// view variable values
QMessageBox::information(this,
"info",
"currentRow = " + nmbr
);
}
void Dialog::on_pushButton_2_clicked()
{
// declare and set variables
QMessageBox::information(this, "Settings","Setting Row and Column");
int currentRow = 3;
int currentCol = 5;
}
void Dialog::on_pushButton_clicked()
{
// view variable values
QString nmbr = QString::number(currentRow);
QMessageBox::information(this,"info","currentRow = " + nmbr);
}
To copy to clipboard, switch view to plain text mode
Bookmarks