cpp11chat/chat_window.hpp

49 lines
994 B
C++
Raw Normal View History

2016-12-04 19:29:47 +00:00
#pragma once
#include <QWidget>
#include <QGridLayout>
#include <QLineEdit>
#include <QListWidget>
class chat_window : public QWidget
{
Q_OBJECT
QGridLayout* _layout;
QListWidget* _chat;
QListWidget* _people;
QLineEdit* _msg;
2016-12-04 19:29:47 +00:00
public:
explicit chat_window(QWidget* parent = 0)
:QWidget(parent)
{ setupUi(); }
public slots:
void return_handler()
{
_chat->addItem(_msg->text());
_msg->clear();
};
2016-12-04 19:29:47 +00:00
private:
2016-12-04 19:29:47 +00:00
void setupUi()
{
this->setWindowTitle("C++11Chat");
this->setMinimumSize(1000, 500);
_layout = new QGridLayout();
_chat = new QListWidget();
_people = new QListWidget();
_msg = new QLineEdit();
connect(_msg, &QLineEdit::returnPressed, this, &chat_window::return_handler);
2016-12-04 19:29:47 +00:00
_layout->addWidget(_chat, 0, 0, 1, 1);
_layout->addWidget(_people, 0, 1, 1, 2);
_layout->addWidget(_msg, 1, 0, 1, 3);
this->setLayout(_layout);
}
};