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 we can run Linux command from qt code?
Forum Updated to NodeBB v4.3 + New Features

How we can run Linux command from qt code?

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 4 Posters 2.5k 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.
  • W Wasee
    6 Jan 2022, 05:18

    @JonB Thanks for your appreciated help!
    Your suggestion of QFile is working fine now.

    QFile f("/sys/bus/iio/devices/iio:device1/out_altvoltage1_TX_LO_frequency");
    if (f.open(QIODevice::WriteOnly))
    {
        qint64 count = f.write("2425000000");
        Q_ASSERT(count > 0);
        f.close();
    }
    

    The value 2425000000 is coming from a variable which can be change any time. I need to pass this value as a variable instead of constant 2425000000.
    thanks

    J Offline
    J Offline
    JonB
    wrote on 6 Jan 2022, 08:18 last edited by
    #21

    @Wasee
    You must convert your (integer) variable to a string. QIODevice::write() accepts either a const char * or a const QByteArray & for the string to write. You can use either QString::number() or QByteArray::number() to convert a number to a string/byte array to pass to write(), as you please.

    1 Reply Last reply
    1

    21/21

    6 Jan 2022, 08:18

    • Login

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