Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. run system() command through qt application

run system() command through qt application

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 5 Posters 4.6k 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.
  • G Offline
    G Offline
    gosk
    wrote on last edited by
    #1

    Hi,

    I cross compiled my qt application and it runs well on my arm development platform. What I want is to run a system() command when a button is pressed.I did something like follow in button's clicked() function.
    @
    Qstring command="cp -r /my_location1 /my_location2";
    const char* command2;

    command2 =command.toLocal8Bit().data();
    system(command2);
    @
    this worked perfecly on my pc. but on target it didnt work.
    I ran my application with ./my_app -qws command. can anyone help me

    thank you.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      You might use "QProcess":http://doc.qt.nokia.com/latest/qprocess.html instead.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on last edited by
        #3

        Using system(3) is usually a bad idea. But the error there is

        @
        command2 =command.toLocal8Bit().data();
        @

        command2 is a dangling pointer after that statement.

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gosk
          wrote on last edited by
          #4

          Hi ,

          thanks a lot. I'll try with qprocess and let you know the result.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gosk
            wrote on last edited by
            #5

            Hi,

            It didn't work. I don't know it has something to do with using -qws option when executing the program in the target. Because the same program works perfectly in my host computer.

            thank you.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              Probably you shold post at least a section of code showing the implementation of QProcess. Furthermore, it might help to provide the error messages, if any.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • U Offline
                U Offline
                uranusjr
                wrote on last edited by
                #7

                Based on my personal experiences, both system() and QProcess should work on embedded devices running QWS, so the -qws option doesn't seem to be the problem (at least not the real problem). Perhaps some information about you devices may help, too.

                On the other hand, if you are only interested in copying files, you can consider using "QFile's copy function":http://doc.qt.nokia.com/latest/qfile.html#copy instead. It should be pretty easy to use.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  gosk
                  wrote on last edited by
                  #8

                  HI,

                  I could resolve the problem. It was a silly mistake. I had used "pushButton_clicked()" function to execute my command whereas it should have been "pushButton_pressed()" function. Now the system works perfectly. thank you everyone. I learnt a lot from you. :)

                  1 Reply Last reply
                  0

                  • Login

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