PDA

View Full Version : Best Method for creating Qt GUI with existing C++ script



Cbr89
14th January 2017, 11:49
Hello everybody :)

I am new to Qt and I am enjoying learning about the functionality.

Although I am not quite sure about how to setup a GUI to work with a script that can already be called as an executable if this is possible.

I will be running the control code on a RPi 3 and dont know if it would be better to have Qt working with the code on the RPi or the laptop/computer that I will ssh into the RPi from.

Any help/ direction would be greatly appreciated! :D

high_flyer
23rd January 2017, 23:34
At least I can't make much sense of the question, probably others too since no one answered it so far...
What it is you are trying to do - again - try not to ask yet how (since as you wrote your self you are not really yet sure "how") - but tell us what it is you need, we probably could then point you in the right direction.

Cbr89
26th January 2017, 07:58
Ok Thank you for the advice, I will try to improve the clarity of my request.

I have a C++ control script on a raspberrypi that works through ssh.

I have a Qt widgets project that displays the two webcam streams from the usb webcams connected to the pi.

As the C++ control script runs on the pi I can see data in the terminal that I would like to display using an progress bar in Qt GUI and also be able to control the motor speed .

1. I would like to display the terminal output in the Qt GUI

2. I would like to use values such as commanded motor speed and actual motor speed (which are refreshed in the terminal output of the control code) to control value indicators (progress bars)

3. I would like to control the input values (command values of the control code) using text input on the GUI. [When the control is running I can use a command such as "setspeed -motor1 5" to set motor 1 at 5% of maximum rpm] I think this step will be much more difficult as it deals with input.

What methods would you suggest to a Qt newbie!?

Thank you for your help. :D

high_flyer
26th January 2017, 13:29
Ok, I think I understand *somewhat* now, but still not everything.

I have a C++ control script on a raspberrypi that works through ssh.
If its C++ it probably is not a script but an application.
Maybe you have a script calling a C++ application?
And, controlling what? - from the following text it seems you mean you want to control camera motors, is that what you mean by "controlling script"?

The three "I would like" points are clear, good.
But, what do you mean with suggesting a method?

The method would be to implement it (not being sarcastic here!).

I guess what I am missing is the problem description.
What is the *problem* you are having?

d_stranz
26th January 2017, 18:17
I have a C++ control script on a raspberrypi that works through ssh.

This also implies that your Qt program -will not be- running on the RPi, but on the computer you are using to ssh into the RPi. Is that correct? ssh is a separate program from your Qt program and there is no built-in communication between the two. So you will either need to redirect the ssh terminal output to a file, socket, or something else that your Qt program can read from or implement the ssh protocol into your Qt program so you can connect to and run the scripts on your RPi from within the Qt program.

I do not know enough about Qt's networking libraries to tell you if this is supported already.

Cbr89
28th January 2017, 19:02
The three "I would like" points are clear, good.
But, what do you mean with suggesting a method?


I am just not sure if there are multiple ways to do this.
Could I access the script when running the C Script through QSerialPort or would another function be best suited?

I saw this thread:

http://stackoverflow.com/questions/40041435/connect-qt-to-raspberry-pi-via-ssh-communication/40052221

However, I cannot find the advantages/disadvantages of each method and which method would be easier/more robust solution.
Also, I am not really sure on how to implement each of these options.

The control code powers two motors. An RPM value is commanded and the terminal returns the measured rpm of the motors. It is these values I want to command and display in my GUI.