added a hander for returnPressed() in QLineEdit of GUI
This commit is contained in:
parent
750554a55a
commit
fa1078a313
@ -10,17 +10,24 @@ class chat_window : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
|
||||||
explicit chat_window(QWidget* parent = 0)
|
|
||||||
:QWidget(parent)
|
|
||||||
{ setupUi(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QGridLayout* _layout;
|
QGridLayout* _layout;
|
||||||
QListWidget* _chat;
|
QListWidget* _chat;
|
||||||
QListWidget* _people;
|
QListWidget* _people;
|
||||||
QLineEdit* _msg;
|
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()
|
void setupUi()
|
||||||
{
|
{
|
||||||
this->setWindowTitle("C++11Chat");
|
this->setWindowTitle("C++11Chat");
|
||||||
@ -31,6 +38,7 @@ private:
|
|||||||
_people = new QListWidget();
|
_people = new QListWidget();
|
||||||
|
|
||||||
_msg = new QLineEdit();
|
_msg = new QLineEdit();
|
||||||
|
connect(_msg, &QLineEdit::returnPressed, this, &chat_window::return_handler);
|
||||||
|
|
||||||
_layout->addWidget(_chat, 0, 0, 1, 1);
|
_layout->addWidget(_chat, 0, 0, 1, 1);
|
||||||
_layout->addWidget(_people, 0, 1, 1, 2);
|
_layout->addWidget(_people, 0, 1, 1, 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user