July 23, 2011

senso senso
Lab Rat
1 posts

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 128×128 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.

1 reply

July 23, 2011

ZapB ZapB
Ant Farmer
1425 posts

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 128×128 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

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

 
  ‹‹ where do i find libQtSerialPort      QwtPlot-resizeEvent Discarding Qualifiers ››

You must log in to post a reply. Not a member yet? Register here!