window telnet linux 失败,在windows下 QProcess 调用Telnet 启动失败?

#include "dialog.h"

#include

#include

#include

Dialog::Dialog(QWidget *parent): QWidget(parent)

{

layout = new QGridLayout(this);

notice = new QLabel("",this);

edit = new QTextEdit(msg,this);

//edit->setEnabled(false);

//edit->setStyleSheet("font:20px;");

layout->addWidget(notice,0,0,1,1);

layout->addWidget(edit,1,0,1,1);

setLayout(layout);

setMinimumWidth(700);

proc= new QProcess(this);

connect(proc, SIGNAL(readyReadStandardOutput()), this,SLOT(readFromStdOut()));

connect(proc, SIGNAL(readyReadStandardError()), this, SLOT(readFromStdErr()));

//connect(proc, SIGNAL(started()), this, SLOT(proceed()));

connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));

connect(proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));

notice->setText(QString("正在登陆..."));

proc->start(QString("telnet bbs.ustc.edu.cn"));

timer = new QTimer(this);

timer->setSingleShot(true);

connect(timer,SIGNAL(timeout()),this,SLOT(timerOut()));

gbk=QTextCodec::codecForName("GBK");

}

void Dialog::paintEvent(QPaintEvent *event)

{

Q_UNUSED(event);

}

Dialog::~Dialog()

{

}

//void Dialog::proceed()

//{

//    proc->write(qPrintable(list[1]+'\n'));

//}

void Dialog::readFromStdOut()

{

msg.append(gbk->toUnicode(proc->readAllStandardOutput()));

QString tmp=msg.split('\n', QString::SkipEmptyParts).last();

if(tmp.contains("suffix"))

{

proc->write("guest\n");

}

edit->setText(msg);

}

void Dialog::readFromStdErr()

{

msg.append(proc->readAllStandardError());

edit->setText(msg);

qDebug()<

}

void Dialog::processError(QProcess::ProcessError error)

{

if(error==QProcess::FailedToStart)

{

msg.append("程序启动失败.");

}

edit->setText(msg);

}

void Dialog::processFinished(int ,QProcess::ExitStatus exitStatus)

{

if(exitStatus == QProcess::CrashExit)

{

msg.append("程序异常终止.");

edit->setText(msg);

}

else

{

//

}

edit->setText(msg);

qDebug()<

timer->start(3000);

notice->setText("quitting in 3 seconds.");

}

void Dialog::timerOut()

{

emit closing();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值