PDA

View Full Version : Predefined parameter in TextFile to control the Output Widget



Shahmisufi
18th October 2016, 05:42
It is normal in GUI, where we will set an Input Widget (Scrollbar, slider, textedit, etc) and will be controlled/ displayed to the Output Widget (ProgressBar, LCD, Label)

Can I control the Output widget instead of using the Input widget, but I'm using a predefined text inside a textfile (.txt) which will be loaded inside the QT?

Example:

I open the notepad, type in '60' , save as ".txt" file and execute my QT program. As it launches, the progress bar inside the window will move to "60", or the LCD will display "60".

Can anyone teach me how to do that?

Thanks;);)

anda_skoa
18th October 2016, 08:04
These output widgets have a setValue() or setText() method (or similar), that can be used to set the value they are displaying.

For reading the file you will need QFile.

The value in a text file is a string, so if the widget needs an integer you will first have to convert that. See QByteArray::toInt().

Cheers,
_