I'm sure this is just a simple problem that I cannot find the answer to, but it is driving me crazy. I am declaring the QString variables oldName and oldAddress in my constructor function, but then when I try to use them in a function that I have in a slot, then I get the error "oldName was not declared in this scope"
Here is the relavent snippet of my code.
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->pushButton_2->hide();
ui->pushButton_3->hide();
ui->lineEdit->setReadOnly(true);
ui->textEdit->setReadOnly(true);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::add()
{
ui->pushButton_2->show();
ui->pushButton_3->show();
ui->pushButton->setEnabled(false);
ui->lineEdit->setReadOnly(false);
ui->textEdit->setReadOnly(false);
oldName = ui->lineEdit->text();
oldAddress = ui->textEdit->toPlainText();
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->pushButton_2->hide();
ui->pushButton_3->hide();
ui->lineEdit->setReadOnly(true);
ui->textEdit->setReadOnly(true);
QString oldName;
QString oldAddress;
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::add()
{
ui->pushButton_2->show();
ui->pushButton_3->show();
ui->pushButton->setEnabled(false);
ui->lineEdit->setReadOnly(false);
ui->textEdit->setReadOnly(false);
oldName = ui->lineEdit->text();
oldAddress = ui->textEdit->toPlainText();
}
To copy to clipboard, switch view to plain text mode
Thank you for your help in advance
Bookmarks