How can I set the string QLineEdit in application with help of other application or shell script?
-
What are you using to have a single instance of your application ?
-
I need some kind of functionality which is detect the change in qApp->arguments() list and notify to QLineEdit for changing string.
There is no «change of arguments». every program has its own set of arguments, and they are fully separated.
the only thin you can do is, from the second prog instance detect that there is already an instance running and send the new strings by inter-process communication.
-
@SGaist I am using windows API and Last save name of application to identify the running instance.
QStringList GetProcessList() { QStringList ret; QProcess process; process.setReadChannel(QProcess::StandardOutput); process.setReadChannelMode(QProcess::MergedChannels); process.start("wmic.exe /OUTPUT:STDOUT PROCESS get Caption"); process.waitForStarted(1000); process.waitForFinished(-1); QTextStream txtStr(&process); while (!txtStr.atEnd()) { auto line = txtStr.readLine().trimmed(); ret << line; } return ret; }
this code will return the QstringList, which is contain
QFileInfo(qApp->applicationFilePath()).fileName();
if application is running. -
You should consider using QtSingleApplication. It's meant for that kind of cases.
-
@Yash001
The fact remains that regardless of the whole single instance issue, as @aha_1980 has said there is no capability to "change command line of a running application".qApp->arguments()
will never return a different result no matter what you try to do. Unless you restart your application for a new string, the only way to approach this will be some kind of IPC connecting to the running program to alter anything in it.