Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Using QTquick 1 to trigger a bash script on button click
QtWS25 Last Chance

Using QTquick 1 to trigger a bash script on button click

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qtquick1.1processqprocessqt4
5 Posts 3 Posters 812 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jcthomas556
    wrote on 20 Jan 2021, 19:29 last edited by jcthomas556
    #1

    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

    R J 2 Replies Last reply 21 Jan 2021, 09:16
    0
    • J jcthomas556
      20 Jan 2021, 19:29

      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

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 21 Jan 2021, 09:16 last edited by
      #2

      @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?!

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      J 1 Reply Last reply 21 Jan 2021, 16:09
      0
      • J jcthomas556
        20 Jan 2021, 19:29

        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

        J Offline
        J Offline
        JonB
        wrote on 21 Jan 2021, 09:22 last edited by
        #3

        @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?

        J 1 Reply Last reply 21 Jan 2021, 16:19
        1
        • R raven-worx
          21 Jan 2021, 09:16

          @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?!

          J Offline
          J Offline
          jcthomas556
          wrote on 21 Jan 2021, 16:09 last edited by
          #4

          @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.

          1 Reply Last reply
          0
          • J JonB
            21 Jan 2021, 09:22

            @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?

            J Offline
            J Offline
            jcthomas556
            wrote on 21 Jan 2021, 16:19 last edited by
            #5

            @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.

            1 Reply Last reply
            0

            3/5

            21 Jan 2021, 09:22

            • Login

            • Login or register to search.
            3 out of 5
            • First post
              3/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved