Reputation: 4688
I would like to alter the GUI ui by using a separate function when an action takes place.
For example: here is my code for a menu item being clicked:
void MainWindow::on_actionImperial_triggered()
{
ui->actionMetric->setChecked(false);
ui->z_unit_label->setText("inches");
void gui_change();
}
I would like the function gui_change()
to be called, and alter the ui.
void gui_change()
{
ui->pushButton_2->setStyleSheet("color:grey");
ui->pushButton->setStyleSheet("color:green");
}
This results in the error use of undeclared identifier 'ui'
, being new to Qt, i have spent a few hours Googling and searching Stack to determine how to get ui
to be within the scope of the function, but have not succeeded.
Upvotes: 0
Views: 651
Reputation: 2718
You need to make gui_change() a member function of MainWindow, and then declare it as void MainWindow::gui_change()
.
If you simply write void gui_change()
, then it is a standalone function that is not part of any class or namespace. (BTW, this is a C++ issue, not a Qt issue)
Upvotes: 2