How we can run Linux command from qt code?
-
@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.
thankswrote on 6 Jan 2022, 08:18 last edited by@Wasee
You must convert your (integer) variable to a string.QIODevice::write()
accepts either aconst char *
or aconst QByteArray &
for the string to write. You can use eitherQString::number()
orQByteArray::number()
to convert a number to a string/byte array to pass towrite()
, as you please.
21/21