How to use UI of one window to another window?
-
wrote on 16 Jan 2022, 15:12 last edited by
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?
-
@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
wrote on 16 Jan 2022, 17:52 last edited by@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
-
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?
wrote on 16 Jan 2022, 15:39 last edited by@Aahi Hi,
I think you need something like:connect(window2_button_reference, &QPushButton::pressed, window1_reference, &Window1ClassName::uncheck_slot_name);
-
@Aahi Hi,
I think you need something like:connect(window2_button_reference, &QPushButton::pressed, window1_reference, &Window1ClassName::uncheck_slot_name);
wrote on 16 Jan 2022, 17:31 last edited by@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
-
@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
wrote on 16 Jan 2022, 17:52 last edited by@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
4/4