User avatar
Posts: 44
Joined: Tue Aug 04, 2015 8:52 pm

my problem with QT and TextBrowser

Mon Oct 03, 2016 8:31 pm

I have a form in QTcreator and I use serial port of RPI2.
I don't use any library like wiring pi, I write my code by linux file read/write function.
I can send any char by serial port,open and close port and...

I have a TextBrowser in my form and I want to show recieving buffer of serial port on it
I want a function that check the serial port for recieving always
and show the recieving in textbrowser (like a serial terminal) but I don't know how ?? !!! :?: :?: :?:

I can recieve 10 char in a simple program with :

Code: Select all

count = read (fd,buff,10);
if (count > 0){
in QT ???
If your Dreams Don't Scare You , They Aren't Big Enough

User avatar
Posts: 6197
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: my problem with QT and TextBrowser

Tue Oct 04, 2016 9:17 am

You probably need to start a separate thread that will read the text from the serialport and then use some "append" method to add the text to the text-widget.
You might not be able to call the method directly so maybe use the Qt signal/slot functionality.

Posts: 3811
Joined: Fri Jun 08, 2012 6:03 pm

Re: my problem with QT and TextBrowser

Tue Oct 04, 2016 9:56 am

You could make use of the built in Qt Serial Port module.
There are some great code example at the link below

Odds are that you'll want to use a timer to periodically update the display with the data from the serial port.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Return to “C/C++”