Important: Please read the Qt Code of Conduct -

How to separate channels when using qprocess?

  • Hey! I mean how can I assign different signals to different buttons? I'm very very new at c++ so, here is my code:


    #include <QObject>
    #include <QProcess>
    class ScriptLauncher : public QObject
        explicit ScriptLauncher(QObject *parent = 0);
        Q_INVOKABLE void launchScript();
        QProcess *m_process;


    #include "scriptlauncher.h"
    #include <QQmlContext>
        ScriptLauncher launcher;
        QQmlApplicationEngine engine;
        QQmlContext *kotu = engine.rootContext();
        kotu->setContextProperty("sLkotu", &launcher);
        QQmlContext *orta = engine.rootContext();
        orta->setContextProperty("sLorta", &launcher);
        QQmlContext *iyi = engine.rootContext();
        iyi->setContextProperty("sLiyi", &launcher);


    #include "scriptlauncher.h"
    ScriptLauncher::ScriptLauncher(QObject *parent) :
        m_process(new QProcess(this))
    void ScriptLauncher::launchScript()


    Connections {
            target: mouseArea
            onClicked: sLiyi.launchScript()
        Connections {
            target: mouseArea1
            onClicked: sLorta.launchScript()
        Connections {
            target: mouseArea2
            onClicked: sLkotu.launchScript()

    codes does work but I don't know how to separete them. Thanks in advance!

  • Moderators

    i think you are over-complicating things here.

    Either you pass a parameter to your launchScript() method.

    Or you create different launcher instances:

    QQmlApplicationEngine engine;
    ScriptLauncher sLkotu("...");
    engine.rootContext()->setContextProperty("sLkotu", &sLkotu);
    ScriptLauncher sLorta("...");
    engine.rootContext()->setContextProperty("sLorta", &sLorta);
    ScriptLauncher sLiyi("...");
    engine.rootContext()->setContextProperty("sLiyi", &sLiyi);

  • @raven-worx hey! Thanks for the help but sadly I couldn't make different launchers work.. How can I pass parameters to launcher as different individual? or maybe you can show me the way to make that launchers work? Sorry for this kinda noobs question. And before I go here is your second; Thanks!

  • Moderators

    WHAT doesn't work?!
    How it is EXACTLY supposed to work?

  • This post is deleted!

  • @raven-worx Sorry haven't look carefuly. Figured it out thanks to you..

Log in to reply