Doubts about using serial ports and how to plot 2d graphics
-
Goodnight, I'm getting started about using Qt and I need/want to have acess to data that comes from a serial port, and as far as I have found Qt doesnt support serial ports nativelly, so I found QSerialDevice and QextSerialPort and I have some doubts about them.
First is, do I compile and put the compiled files in some library folder of the Qt Creator or I just copy all the code when I need to use it?
The other is, if there are two different implementations, what is the best one?Then there is my another doubt, how can I for example receive an 128x128 pixels gray-scale image and then plot it into the user interface window? The doubt is really if there are Qt functions to help plotting 2d data into a specific graph area.
Thanks in advance for all the help.
-
I have used QextSerialPort for many years and am very happy with it. Usually one would build it as a shared library and link your own applications and libraries to it in the usual way (ie edit the LIBS variable in your .pro file).
As for your second question, how you receive the data back is entirely dependent upon what protocol your serial device is using layered on top of the standard RS232 comms protocol. A library like QextSerialPort and the OS take care of the RS232 part but you are responsible for anything above that.
If you can get the bytes of your 128x128 greyscale image then you can create a QImage from them (see the many QImage constructors). You can then use a QLabel (or your own custom widget and QPainter) to show the image.
HTH