I have the code:
void Processmethod()
{
QDialog *ProcessMessage = new QDialog;
// HOW TO CONNECT THE DIALOGS PUSHBUTTON TO KILL THE PROCESS called in processmethodONE() ?
Ui::DialogProcessMessage Dialog; //polymorphy
Dialog.setupUi(ProcessMessage);
ProcessMessage->setModal(true);
ProcessMessage->setAttribute(Qt::WA_DeleteOnClose);
ProcessMessage->show();
processmethodONE();
}
void processmethodONE()
{
QString ProcessCommand = "w8 " + blablubli";
Prozess.setWorkingDirectory(Path); //QProcess "Prozess" is globaly defined
Prozess.setStandardOutputFile(Path); //in my class
QEventLoop loop;
connect(&Prozess, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
connect(&Prozess, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
Prozess.start(ProcessCommand);
loop.exec();
QProcess::ExitStatus Status = Prozess.exitStatus();
if (Status == 0)
{
std::cout <<"Exit-Status: " << Status << " File created!" << std::endl;
}
else
{
std::cout << "Exit-Status: " << Status << " Error-Code: " << Prozess.error() << "Process failed!" << std::endl;
}
}
What I want to do, is to kill the QProcess "Prozess" by one of the dialogs pushButtons. The class "Ui::DialogProcessMessage" can't be edited/specified since it is the class directly constructed by the QtDesigner Ui-File and therefore will be overwritten anytime the Ui-File is edited with QtDesigner. How can I handle this? greetings
The solution is just to use
connect(Dialog.pushButtonAbort, SIGNAL(clicked()), &Prozess, SLOT(kill()));
Probably it is, because Dialog is the "main object" in this case and the object "ProcessMessage" is just used to specify it. Got this from the QDeveloper forum.
THX for the support guys.