Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Using QTquick 1 to trigger a bash script on button click



  • Hello, I'm trying to get my lightdmkde set up to trigger a bash script on clicking shutdown. I'm trying to edit the main.qml file that manages the shutdown buttons, but am having a difficult time calling the QProcess. It seems to break the display anytime I add anything QProcess related.

    It is my understanding that at the header it will need to import process in some way, though I've seen some back and forth on this. Also that it will need something like this

    QProcess process;
    process.start("dir \"\"\"My Documents\"\"\"");
    

    https://doc.qt.io/archives/qt-4.8/qprocess.html#startDetached

    I tried to add that QProcess line with and w/o any imports, both break my display. I've also tried adding an import header by itself, but that also broke my display so I must have something wrong with it.

    This is what I'd like:

    PlasmaWidgets.IconWidget {
                    text: i18n("Shutdown")
                    icon: QIcon("system-shutdown")
                    enabled: power.canShutdown;
                    onClicked: callMyOwnShutdownScript();
                } 
    

    Any tips would be appreciated, this is my first time working with anything QT related


  • Moderators

    @jcthomas556 said in Using QTquick 1 to trigger a bash script on button click:

    It seems to break the display anytime I add anything QProcess related.

    what does "breaking the display" mean exactly?!



  • @jcthomas556
    I don't know anything about running bash under Windows. But, although this is probably not related to your error, how did you come up with this string? It resolves to dir """My Documents""". This looks both to have too many quotes and to name a path relative to your app's current directory, neither of which sound right?



  • @raven-worx Sorry, should have clarified. The login screen is what I'm looking at, and when the display "breaks" What I see is all the buttons and accounts to choose from disappear, so all that's left is the blank white page.



  • @JonB This is a quote from the example given on the link listed. It's from QT, in an explanation of how this works. It's not a string that I came up with, or that I'm using.