How to use UI of one window to another window?
-
let's say I have two windows main_window and second_window, In main window I have "ui->checkBox->setChecked(true);" in main_window constructor and in second window I have a push_button and I want to uncheck the checkBox of main_window using the push_button of second_window so Basically in second_window I want to do is "main_window::ui->checkBox->setChecked(false);"
So how can I do that also I don't want to change the ui from private to public?
-
@Aahi You don't have to use this old connection style. Remove SIGNAL and SLOT words.
auto window2 = new MainWindow(); connect(ui->pushButton, &QPushButton::pressed, window2, &MainWindow::some_slot_that_you_have_in_MainWindow_class);
some_slot_that_you_have_in_MainWindow_class() { ui->checkBox->setChecked(false); }
Something like that
-
@goloviznin-k It didn;t work this is what I write
connect(ui->pushButton, SIGNAL(&QPushButton::pressed),new MainWindow(), SLOT( &MainWindow::ui->checkBox->setChecked(false)));
window1 = MainWindow
window2 = enter_mail (don't ask why)It didn't uncheck the the checkBox from window1
-
@Aahi You don't have to use this old connection style. Remove SIGNAL and SLOT words.
auto window2 = new MainWindow(); connect(ui->pushButton, &QPushButton::pressed, window2, &MainWindow::some_slot_that_you_have_in_MainWindow_class);
some_slot_that_you_have_in_MainWindow_class() { ui->checkBox->setChecked(false); }
Something like that