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?
Qt 6.11 is out! See what's new in the release blog

How we can run Linux command from qt code?

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 4 Posters 4.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.
  • WaseeW Wasee

    @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

    JonBJ Online
    JonBJ Online
    JonB
    wrote on 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

    • Login

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