i want to send data in serial i write code like
In receiver side the value is splited like "WELCOME" splited to W ELCOME
why the string is splited
The string is split as data comes in groups.
This is normal, and its your job to put it back together again while reading.
i want to click button one time only
It has nothing to with clicking a button
When Data signal comes
QByteArray str; // this should live in class
str.append(serial->readAll()); // append to buffer for each read
when str.size() is big enough that you know all data have been read, you can then look at the data.
There is NO WAY to make sure that it only takes 1 serial->readAll()
to get all data.
Most common way would be defining a very simple protocol used to deliver your data via serial port.
In your case, you may just add a <newline> to the data you want to transmit. On the receiver side, you can then wait for that <newline> (using the mechanism already mentioned) to identify the end of the transmission and that your received data is now complete.
However this only works if your data itself does not contain a <newline>. In that case you will need to use another "marker" or define a more complex protocol.