MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
//qhboxLayout1部分代码
QLabel* monitorLabel= new QLabel("监听端口");
m_monitorSpinBox = new QSpinBox();
m_monitorSpinBox->setRange(0,65535);
m_startButton = new QPushButton("启动服务");
m_stopButton = new QPushButton("停止服务");
m_stopButton->setEnabled(false);
QHBoxLayout *qhboxLayout1 = new QHBoxLayout;
qhboxLayout1->addWidget(monitorLabel);
qhboxLayout1->addWidget(m_monitorSpinBox);
qhboxLayout1->addWidget(m_startButton);
qhboxLayout1->addWidget(m_stopButton);
//qhboxLayout2部分代码
QLabel* sendLabel=new QLabel("发送消息");
QHBoxLayout *qhboxLayout2 = new QHBoxLayout;
qhboxLayout2->addWidget(sendLabel);
//qhboxLayout3部分代码
m_sendTextedit = new QTextEdit;
m_sendTextedit->setEnabled(false);
m_sendTextedit->setFixedHeight(50);
m_sendButton= new QPushButton("发送");
m_sendButton->setEnabled(false);
m_sendButton->setFixedHeight(50);
QHBoxLayout *qhboxlayout3 = new QHBoxLayout;
qhboxlayout3->addWidget(m_sendTextedit,2);
qhboxlayout3->addWidget(m_sendButton,1);
//qvboxlayout411
QLabel* receiveLabel = new QLabel("接收消息");
m_receiveTextEdit = new QTextEdit();
m_receiveTextEdit->setReadOnly(true);
QVBoxLayout *qvboxlayout411 = new QVBoxLayout;
qvboxlayout411->addWidget(receiveLabel);
qvboxlayout411->addWidget(m_receiveTextEdit);
//qhboxlayout412
m_cleanButton = new QPushButton("清除");
m_cleanButton->setEnabled(false);
QHBoxLayout *qhboxlayout412 = new QHBoxLayout;
qhboxlayout412->addStretch();
qhboxlayout412->addWidget(m_cleanButton);
//qvboxlayout41
QVBoxLayout *qvboxlayout41 = new QVBoxLayout;
qvboxlayout41->addLayout(qvboxlayout411);
qvboxlayout41->addLayout(qhboxlayout412);
//qvboxlayout42
QLabel* linkclientLabel=new QLabel("连接客户端");
m_linkclientListWidget=new QListWidget;
QVBoxLayout* qvboxlayout42 = new QVBoxLayout;
qvboxlayout42->addWidget(linkclientLabel);
qvboxlayout42->addWidget(m_linkclientListWidget);
//qvboxlayout4
QHBoxLayout *qhboxlayout4 = new QHBoxLayout;
qhboxlayout4->addLayout(qvboxlayout41,2);
qhboxlayout4->addLayout(qvboxlayout42,1);
//mainlayout
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(qhboxLayout1,1);
mainLayout->addLayout(qhboxLayout2,0.5);
mainLayout->addLayout(qhboxlayout3,1);
mainLayout->addLayout(qhboxlayout4,3);
//this->setLayout(mainLayout);
this->setWindowTitle("Websocket Server");
ui->setupUi(this);
ui->centralWidget->setLayout(mainLayout);
}