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. [SOLVED] Passing an integer value in QProcess
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Passing an integer value in QProcess

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 3.1k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    amban
    wrote on last edited by
    #1

    Hi,
    I have written a bash script which queries my MqSQL database in a remote server. I have written several QProcess cases but those involved no input. Now i want to pass an integer value i.e the job-id to execute my bash script. When i do a

    @
    proc->start("path/to/bash/script" , QSringList () << "a_string");
    @

    my script doesnt run (because the passed argument is a string)

    Please help.

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      Why are you using a bash script to wrap a SQL query? Why not just use QSqlQuery and friends?

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tobias.hunger
        wrote on last edited by
        #3

        Scripts only take string arguments, so I am not sure what the problem is...

        Do you need to convert a integer to a string? Check QString::number(...) for that.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          amban
          wrote on last edited by
          #4

          Ok i solved it. My fault, it was simple concatenation of Qstrings.
          So now i have
          @Qstring command = "/path/to/bash/script" ;
          QString input = ui->lineEdit->text();
          command.append(input);

                              QProcess *p = new QProcess();
                              p.start(command);@
          

          Thanks for all your help.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            loladiro
            wrote on last edited by
            #5

            as Tobias said, use "QString::number":http://doc.qt.nokia.com/4.7/qstring.html#number

            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