Opening a new form with a push_button
-
I'm trying to open a new form with a push Button. i've seen examples on YouTube but can't get it working.
My main form is called: srm.ui
It has a button 'PB_driver_settings' And I want to open the form drivers.ui when I press the button.In my srm.h I have included ui_drivers.h
and added a line in the private section:
private:
Ui::SRM *ui;
Ui_driver_update driver_update;What should I do to make the correct call.
I don't know the argument to add.
void SRM::on_PB_Driver_Settings_clicked()
{
driver_update.setupUi();
}I exampled I saw a call to a function .show() but that is not working either.
-
You don't need to include ui_* include files.
include drivers.h file in your srm.h file (you can do forward declaration but for simplicity lets not do that.
#include "driver.h"
Define a variable (preferrabley private) for Driver object.
Driver *driverWindow;
In SRM's constructor create the driverWindow object
driverWindow = new Driver(this);
and your slot:
void SRM::on_PB_Driver_Settings_clicked() { driverWindow->exec(); }