I have a Qt application in which I want to put a restart button, but when it restarts I want it to automatically reconnect with my bluetooth device. here's my code:

Qt Code:
  1. void gui::restartapp()
  2. {
  3. int index_combo;
  4.  
  5. index_combo= ui->devices_infile->currentIndex();
  6.  
  7. QProcess::startDetached(QApplication::applicationFilePath());
  8. exit(12);
  9.  
  10. char *dest;
  11. dest = addr_infile[index_combo];
  12.  
  13. sock = linkup_directmain(dest, sock);
  14.  
  15. if (sock != 0 && sock >0)
  16. {
  17. ui->console_1->setText("Connected to:");
  18. ui->console_2->setText(name_infile[index_combo]);
  19. }
  20.  
  21. else if (sock == -1)
  22. {
  23. ui->console_1->setText("Error connecting");
  24. ui->console_2->setText("Check device status");
  25. }
  26. }
To copy to clipboard, switch view to plain text mode 

but it only restarts. any idea?

Thank you in advance.