Establishing client-server communication
In this recipe, we will learn to make a client and will see how it can send messages to the server. The main idea is to understand how a message is sent, how the server listens to the port, and how communication is established between the two.
How to do it...
To send messages to the server, we will be making use of the Line Edit
 and Push Button
widgets. The message written in the Line Edit
widget will be passed to the server on the click of the push button. Here is the step-by-step procedure for creating a client application:
- Create another application based on the
Dialog without Buttons
template. - AddÂ
QLabel
,QTextEdit
,QLineEdit
, andQPushButton
to the form by dragging and dropping theLabel
,Text Edit
,Line Edit
, andPush Button
widgets on the form. - Set the
text
property of theLabel
widget toClient
. - Set the
text
property of thePush Button
widget toSend
. - Set the
objectName
property of theText Edit
widget totextEditMessages
. - Set the
objectName
property...