How to set window to active window based on QProcess?
Code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QTextStream>
#include <QTime>
#include <QProcess>
#include <QFile>
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->statusBar->showMessage("Waiting for input...");
QMessageBox::information(0,
"Error",
file.
errorString());
}
path = in.readLine();
file.close();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_2_clicked()
{
qApp->exit();
}
void delay(int n)
{
while(QTime::currentTime() < dieTime
) }
void MainWindow::on_pushButton_clicked()
{
ui->pushButton->setEnabled(false);
qint32 waitSecs = ui->lineEdit->text().toInt();
QTime launchTime
= QTime::currentTime().
addSecs(waitSecs
);
while(waitSecs > 0) {
waitSecs
= QTime::currentTime().
secsTo(launchTime
);
ui
->statusBar
->showMessage
(QString("Waiting %1 seconds to launch BLR launcher.").
arg(waitSecs
));
delay(1);
}
ui->statusBar->showMessage("Launching BLR launcher!");
// Focus launcher
ui->statusBar->showMessage("Waiting for patch to finish...");
/*while True:
ImageGrab.grab().save("haystack.png")
if detectImage():
break
else:
time.sleep(3)*/
ui->statusBar->showMessage("Shutting PC down in 60 seconds! Exit this program to abort.");
/*time.sleep(60)
subprocess.Popen(['shutdown', '-s', '-t', '0'])*/
}
As you can see from the code above (read the last 4 lines), I have a process that is started. I want to make sure that the window that starts (by that process) is focused.
I know there is this function: http://qt-project.org/doc/qt-4.8/qap...etActiveWindow
It requires a QWidget as a parameter. Maybe I need to convert QProcess to Qwidget?
Re: How to set window to active window based on QProcess?
I am not sure what you mean. Do you want to activate a window of your first application or a window of the second application (the one started by QProcess)?
Cheers,
_