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:
void gui::restartapp()
{
int index_combo;
index_combo= ui->devices_infile->currentIndex();
exit(12);
char *dest;
dest = addr_infile[index_combo];
sock = linkup_directmain(dest, sock);
if (sock != 0 && sock >0)
{
ui->console_1->setText("Connected to:");
ui->console_2->setText(name_infile[index_combo]);
}
else if (sock == -1)
{
ui->console_1->setText("Error connecting");
ui->console_2->setText("Check device status");
}
}
void gui::restartapp()
{
int index_combo;
index_combo= ui->devices_infile->currentIndex();
QProcess::startDetached(QApplication::applicationFilePath());
exit(12);
char *dest;
dest = addr_infile[index_combo];
sock = linkup_directmain(dest, sock);
if (sock != 0 && sock >0)
{
ui->console_1->setText("Connected to:");
ui->console_2->setText(name_infile[index_combo]);
}
else if (sock == -1)
{
ui->console_1->setText("Error connecting");
ui->console_2->setText("Check device status");
}
}
To copy to clipboard, switch view to plain text mode
but it only restarts. any idea?
Thank you in advance.
Bookmarks