added a hander for returnPressed() in QLineEdit of GUI

This commit is contained in:
Kjistóf 2016-12-04 20:30:27 +01:00
parent 750554a55a
commit fa1078a313
1 changed files with 14 additions and 6 deletions

View File

@ -10,17 +10,24 @@ class chat_window : public QWidget
{
Q_OBJECT
public:
explicit chat_window(QWidget* parent = 0)
:QWidget(parent)
{ setupUi(); }
private:
QGridLayout* _layout;
QListWidget* _chat;
QListWidget* _people;
QLineEdit* _msg;
public:
explicit chat_window(QWidget* parent = 0)
:QWidget(parent)
{ setupUi(); }
public slots:
void return_handler()
{
_chat->addItem(_msg->text());
_msg->clear();
};
private:
void setupUi()
{
this->setWindowTitle("C++11Chat");
@ -31,6 +38,7 @@ private:
_people = new QListWidget();
_msg = new QLineEdit();
connect(_msg, &QLineEdit::returnPressed, this, &chat_window::return_handler);
_layout->addWidget(_chat, 0, 0, 1, 1);
_layout->addWidget(_people, 0, 1, 1, 2);