赞
踩
.h #ifndef DIALOG_H #define DIALOG_H #include <QDialog> #include <QLabel> #include <QPushButton> #include "timeserver.h" #include <QMessageBox> class Dialog : public QDialog { Q_OBJECT public: Dialog(QWidget *parent = 0); ~Dialog(); private: QLabel *label1; QLabel *label2; QPushButton *quitBtn; public slots: void slotShow(); private: TimeServer *timeServer; int count; }; #endif // DIALOG_H
.cpp #include "dialog.h" #include <QHBoxLayout> #include <QVBoxLayout> Dialog::Dialog(QWidget *parent) : QDialog(parent) { setWindowTitle("多线程时间服务器"); label1=new QLabel("服务器端口"); label2=new QLabel; quitBtn=new QPushButton("退出"); QHBoxLayout *BtnLayout =new QHBoxLayout; BtnLayout->addStretch(1); BtnLayout->addWidget(quitBtn); BtnLayout->addStretch(1); QVBoxLayout *mainLayout=new QVBoxLayout(this); mainLayout->addWidget(label1); mainLayout->addWidget(label2); mainLayout->addLayout(BtnLayout); connect(quitBtn,SIGNAL(clicked()),this,SLOT(close())); count=0; timeServer = new TimeServer(this); if(!timeServer->listen()) { QMessageBox::critical(this,tr("多线程时间服务器"), tr("无法启动服务器:%1.").arg(timeServer->errorString()));//无法监听报错 close(); return; } label1->setText(tr<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。