i have 2 form(design by UI) . i want that when iclick button from form1 then form 2 will show and form1 hide

i try thid code but it is not work

Qt Code:
  1. QWidget * widgt= new QWidget();
  2. Ui::Form2 ui;
  3. ui.setupUi(widgt);
  4.  
  5. Form2 *detail = new Form2 (urlImage,index,widgt);
  6. detail->show();
To copy to clipboard, switch view to plain text mode