47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
|
#include "custom.h"
|
||
|
|
||
|
Custom::Custom(QWidget *parent)
|
||
|
: QWidget(parent)
|
||
|
{
|
||
|
// 初始化窗口的控件
|
||
|
nameEdit = new QLineEdit(this);
|
||
|
nameEdit->resize(200,40);
|
||
|
nameEdit->move(10,10);
|
||
|
|
||
|
nEdit = new QLineEdit(this);
|
||
|
nEdit->resize(100,40);
|
||
|
nEdit->move(10,60);
|
||
|
|
||
|
toOrderBtn = new QPushButton("下单",this);
|
||
|
toOrderBtn->resize(80,40);
|
||
|
toOrderBtn->move(10,110);
|
||
|
|
||
|
eatStateLable = new QLabel("未开吃",this);
|
||
|
eatStateLable->resize(100,40);
|
||
|
eatStateLable->move(10,160);
|
||
|
|
||
|
// 设置按钮的点击事件的处理函数
|
||
|
connect(toOrderBtn,&QPushButton::clicked,this,&Custom::toOrderHandle);
|
||
|
}
|
||
|
|
||
|
void Custom::toOrderHandle()
|
||
|
{
|
||
|
eatStateLable->setText("等待上菜……");
|
||
|
// 下单按钮被点击了
|
||
|
qDebug() << "准备下单了";
|
||
|
qDebug() << "你的菜品: "<< nameEdit->text() << ", 数量:" << nEdit->text();
|
||
|
|
||
|
// 向店家发送信号,信号中包含菜品名和数量
|
||
|
emit toOrderSignal(nameEdit->text(), nEdit->text().toInt());
|
||
|
}
|
||
|
|
||
|
void Custom::okOrderHandle()
|
||
|
{
|
||
|
eatStateLable->setText(nameEdit->text()+"开吃……");
|
||
|
}
|
||
|
|
||
|
Custom::~Custom()
|
||
|
{
|
||
|
}
|
||
|
|