Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I send the command to console?
Forum Updated to NodeBB v4.3 + New Features

How can I send the command to console?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.3k 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.
  • V Offline
    V Offline
    victor wang
    wrote on last edited by A Former User
    #1

    HI, I'm using Qt5.5 on my computer.
    I'm wanna send this two commands to my console

    cd /run/media/sda1
    sync
    

    I do not know how to do it.
    Please help!

    Manohar_SLM 1 Reply Last reply
    0
    • V victor wang

      HI, I'm using Qt5.5 on my computer.
      I'm wanna send this two commands to my console

      cd /run/media/sda1
      sync
      

      I do not know how to do it.
      Please help!

      Manohar_SLM Offline
      Manohar_SLM Offline
      Manohar_SL
      wrote on last edited by
      #2

      @victor-wang you can use
      QString cmd = "sync";
      system(cmd);

      Regards
      Manu

      Manohar SL
      Embedded Qt & QML Developer

      V 1 Reply Last reply
      1
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        http://stackoverflow.com/questions/40407394/qt-run-shell-commands-via-qprocess

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        V 1 Reply Last reply
        4
        • Manohar_SLM Manohar_SL

          @victor-wang you can use
          QString cmd = "sync";
          system(cmd);

          Regards
          Manu

          V Offline
          V Offline
          victor wang
          wrote on last edited by
          #4

          @Manohar_SL
          I got an error when compiling.
          The error is here

          This is my code here

          It cannot convert QString to char, what should i do ?

          1 Reply Last reply
          1
          • VRoninV VRonin

            http://stackoverflow.com/questions/40407394/qt-run-shell-commands-via-qprocess

            V Offline
            V Offline
            victor wang
            wrote on last edited by
            #5

            @VRonin
            Thank you for your information.
            I have solved my problem!
            Thank you so much!
            @Manohar_SL
            Thank you i have solved the problem in the other way.

            1 Reply Last reply
            2

            • Login

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