1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #include "window.h"
Window::Window(): QWidget()
{
setFixedSize(600, 400);
m_start = new QPushButton("Start Server");
m_shut = new QPushButton("Shut Down");
QTextEdit *log = new QTextEdit;
log->setReadOnly(true);
log->setFont(QFont("Courier"));
log->setLineWrapMode(QTextEdit::NoWrap);
QHBoxLayout *footer = new QHBoxLayout();
footer->addWidget(m_start);
footer->addWidget(m_shut);
QGridLayout *window = new QGridLayout();
window->addWidget(log, 0, 1);
window->addLayout(footer, 1, 0, 1, 2);
setLayout(window);
QObject::connect(m_start, SIGNAL(clicked()), this, SLOT(Config()));
QObject::connect(m_shut, SIGNAL(clicked()), this, SLOT(close()));
Server myServer(1111);
std::thread serverThread([this, &myServer]()
{
Window::ListenToClients(myServer);
});
}
void Window::Config()
{
config.exec();
}
void Window::ListenToClients(Server &myServer)
{
for(int i = 0; i < 100; i++)
{
myServer.ListenNewConnections();
}
} |
Partager