Problem is already described in title: I'm using a QDial
to set contrast level of a LCD 7" display (connected to an embedded Linux Single Board Computer).
Simple way to do this is to send on terminal an "echo" instruction. I send it as a QFile:
QFile ContrLCD("/sys/class/backlight/backlight/brightness");
and I need to send the level writing in this QFile
ContrLCD.write("number");
Problem is QDial
manage int
variable, while QFile
requires const char*
to send number corresponding to contrast.
How to do this?
This example is taken from the documentation for QFile
:
QFile file("out.txt"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return; QTextStream out(&file); out << "The magic number is: " << 49 << "\n";
Seems like you can use a QTextStream
to write formatted output to a QFile
. I did not use it myself, so there might be other ways, but for formatted output of numbers this seems to be the right tool.