我有一个Qt应用程序,我想在其中重新启动按钮,但是当它重新启动时,我希望它自动重新连接我的蓝牙设备。这里是我的代码:重新启动应用程序与以前的一些东西
// Restart app
void gui::restartapp()
{
int index_combo;
index_combo= ui->devices_infile->currentIndex();
QProcess::startDetached(QApplication::applicationFilePath());
QCoreApplication::exit()
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");
}
}
但它只是重新启动。任何想法?
预先感谢您。
更新:
我得到它的工作。我会稍后发布它,以防别人需要它。
'exit(12)'是什么?''做? – 2013-03-13 15:00:42
对不起。它应该是0.我的坏。 – SamuelNLP 2013-03-13 15:03:24
所以后面的代码'exit(0);'永远不会执行? – 2013-03-13 15:04:47