Hi,
I am relatively new to Qt and have encountered a problem with my last project.
My work computer is running Windows 10 and I'm using Qt 6.6.0 and MinGW.
I have already written a few programs, which fully serve their purpose. In my latest project, I wanted to be able to call another program that I had previously written. I have previously deployed this using the MinGW console and the command "windeployqt .", so that I have all the dependencies and can also open the program from other (Windows) computers.
In my new project, I can open other programs using QProcess::startDetached() (tested on 9 different ones), but only my self-written and deployed ones cannot be opened.
Since I am new to Qt, it is possible that I have overlooked something, does anyone have any advice for me?
Here is the minimal example of my latest project:
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPushButton>
#include <QGridLayout>
#include <QProcess>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
{
Q_OBJECT
public:
MainWindow
(QWidget *parent
= nullptr
);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void open_program();
};
#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPushButton>
#include <QGridLayout>
#include <QProcess>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void open_program();
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
MainWindow w;
w.show();
return a.exec();
}
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
) , ui(new Ui::MainWindow)
{
ui->setupUi(this);
layout -> addWidget(but_open, 0, 0);
ui->centralwidget->setLayout(layout);
connect(but_open, SIGNAL(clicked()), this, SLOT(open_program()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::open_program() {
QString pfad
= "I:\\FabTech\\Anlagen-Dokumentation\\85 TEOS 200 mm\\Teos-Trapping\\TEOS-Überwachung\\TEOS-Abscheidungs-Programm\\TEOS_Abscheidung.exe";
process.startDetached(pfad);
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
QPushButton* but_open = new QPushButton("Open");
QGridLayout *layout = new QGridLayout();
layout -> addWidget(but_open, 0, 0);
ui->centralwidget->setLayout(layout);
connect(but_open, SIGNAL(clicked()), this, SLOT(open_program()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::open_program() {
QProcess process;
QString pfad = "I:\\FabTech\\Anlagen-Dokumentation\\85 TEOS 200 mm\\Teos-Trapping\\TEOS-Überwachung\\TEOS-Abscheidungs-Programm\\TEOS_Abscheidung.exe";
process.startDetached(pfad);
}
To copy to clipboard, switch view to plain text mode
I can also start any number of instances of the program to be called from Windows while the program is running, but not from the new program. When the button is pressed, a window opens for a barely recognizable period of time and then closes again immediately.
Thanks in advance,
Qt_Bob
Bookmarks