注册 登录
编程论坛 QT论坛

求助,谁能给解释下这片代码,本人没看懂

IRonblade 发布于 2016-03-16 10:07, 4310 次点击
QString tmp;
    tmp = tcpSocket->readAll();

    if(tmp.contains("   @") ){
        ui->listWidget->clear();
        tm = tmp.split("   @");
        for(int i = 0; i < tm.count(); i ++){
                ui->listWidget->addItem(tm.at(i));
        }
    }else if(tmp.startsWith("&&")){
        sm = tmp.split("&&");
        if(sm.at(3) == ip ){
            bbb->chuanMessage( "<font color=blue>[自已]</font>" + sm.at(3) + ":<br>" + sm.at(2));
            if(sm.at(1) == ip){
                bbb->chuanMessage("<font color=red>[对方]</font>" + sm.at(3) + ":<br>" + sm.at(2));
            }
        }
        if(sm.at(1) == ip ){
            if(sm.at(3) != ip){
                bbb->show();
                bbb->chuanIP(sm.at(3),ui->lineEdit_server->text());
                bbb->chuanMessage("<font color=red>[对方]</font>" + sm.at(3) +":<br>" + sm.at(2));
            }
        }
        qDebug()<<"readMessage over!";
    }else if(tmp.startsWith("|") ){
        rm = tmp.split("|");
        rece_ip = rm.at(2);
        pps = tmp.split("/");

        if(ip == rece_ip){
            ccc->show();
            ccc->fileName(pps.at(pps.count() -1), rm.at(1));
            bbb->chuanMessage(rm.at(1) + "给你传文件!" + rm.at(3));
        }
    }else if(tmp.startsWith("$$$")){
        bbb->send_();
    }
    else if(tmp.startsWith("*^*")){
        bbb->chuanMessage(tmp);
    }
    else{
    ui->textEdit->append( tmp );
0 回复
1