A P2P chat application client for local area network (Windows) developed using Qt5 and C++.
-
Qt5/C++ development
-
Qtcreator/Qtquick design UI
3.Qml+Qss beautify the interface
-
Customize Qtsocket list (array container) to maintain multi-party P2P connection
-
Rewrite the mouse click event to realize the small right-click menu of the friend list
-
Use Qtquick to maintain a message panel list for each friend who is chatting
-
Use MapSignal to pass custom parameters to the SLOT function of connect to switch the corresponding Socket
-
Add/remove friends
-
Personal/friend business card (avatar, nickname, profile)
-
Send a heartbeat packet to the intermediate server to maintain the state
-
Multi-branch P2P chat
-
File transfer (confirmation mechanism) (larger files can be transferred)
-
One-to-one chat message panel
2. QSignalMapper does the mapping of binding events (solves the problem that SLOT cannot pass parameters)
ServerMapper->setMapping(LinkInfo.ListTcpsocket.last(),LinkInfo.ListTcpsocket.count());
connect(LinkInfo.ListTcpsocket.last(), SIGNAL(readyRead()), ServerMapper, SLOT(map()));
connect(ServerMapper, SIGNAL(mapped(int)), this, SLOT(changeTempTcpsocket(int)));
QByteArray data;
data.resize(sizeof(LoginMessage));
QBuffer buffer(&data);
buffer.open(QIODevice::WriteOnly);
QDataStream out(&buffer);
LoginMessage Message;
Message.type=UsrLogin;
qDebug()<<user_id <<user_password<<endl;
Message.userid=user_id;
Message.password=user_password;
Message.Message="I want to login in,please.";
out<<Message.type<<Message.userid<<Message.password<<Message.Message<<true;
buffer.close();
QByteArray data = this->tcpSocket->readAll();
QBuffer buf(&data);
buf.open(QIODevice::ReadOnly);
QDataStream in(&buf);