TestPing::TestPing(QWidget *parent, Qt::WFlags flags):QWidget(parent, flags)
{
font.setFamily("wenquanyi");
font.setPointSize(20);
inputLabel = new QLabel(tr("Input CMD:"));
inputEdit = new QLineEdit;
runButton = new QPushButton(tr("Go"));
stopButton = new QPushButton(tr("Quit"));
outputLabel = new QLabel(tr("Out Window:"));
outputEdit = new QTextEdit;
inputLabel ->setFont(font);
inputEdit ->setFont(font);
runButton->setFont(font);
stopButton->setFont(font);
outputLabel->setFont(font);
outputEdit->setFont(font);
outputEdit->setReadOnly(true);
hlayout = new QHBoxLayout; //水平排列
hlayout->addWidget(inputEdit);
hlayout->addWidget(runButton);
hlayout->addWidget(stopButton);
layout = new QVBoxLayout; //垂直排列
layout->addWidget(inputLabel);
layout->addLayout(hlayout);
layout->addWidget(outputLabel);
layout->addWidget(outputEdit);
setLayout(layout);
cmd = new QProcess;
stopcmd = new QProcess;
connect(inputEdit, SIGNAL(returnPressed()), this, SLOT(runClicked()));
connect(runButton, SIGNAL(clicked(bool)), this, SLOT(runClicked()));
connect(stopButton, SIGNAL(clicked(bool)), this, SLOT(stopClicked()));
connect(cmd, SIGNAL(readyRead()), this, SLOT(readOutput()));
}
TestPing::~TestPing() //close后程序是否是自动释放空间的?
{
delete inputLabel;
delete inputEdit;
delete runButton;
delete stopButton;
delete outputLabel;
delete outputEdit;
delete hlayout;
delete layout;
delete cmd;
delete stopcmd;
}
这里我是否需要人工释放内存??
我是通过一个信号将窗口关闭(这是个子窗口)
QObject::connect(this, SIGNAL(quitPing()), this, SLOT(close()));
emit quitPing();