资源简介
在Linux下用Qt写的无线点菜系统。用Qt程序做出图形界面,再用SOcket和Client实现点菜系统的接收和发送。
代码片段和文件信息
#include “choosemenu.h“
#include “openroom.h“
//#include “sendselectedmenus.h“
#include
#include
#include
#include
#include
#include
#include
//extern currentRoom;
extern bool room1Flag room2Flagroom3Flagroom4Flagroom5Flagroom5Flagroom6Flagroom7Flagroom8Flag;
//extern int currentRoom;
ChooseMenu::ChooseMenu(QWidget *parent):QDialog(parent)
{
//currentRoom = 0;//set the current room is invalid
addButton = new QPushButton(“add“);
removeButton = new QPushButton(“remove“);
okButton = new QPushButton(“ok“);
backButton = new QPushButton(“back“);
supplyMenuListWidget = new QListWidget;
menuList = new QStringList;
readMenu();
/*//test data
supplyMenuListWidget->addItem(“seafish 100“);
supplyMenuListWidget->addItem(“sayu 200“);
supplyMenuListWidget->addItem(“beke 150“);
supplyMenuListWidget->addItem(“baicai 10“);
supplyMenuListWidget->addItem(“potato 20“);
supplyMenuListWidget->addItem(“tomato 15“);
supplyMenuListWidget->addItem(“meat 80“);
supplyMenuListWidget->addItem(“niurou 100“);
supplyMenuListWidget->addItem(“sanyang 300“);*/
supplyMenuListWidget->addItems(*menuList);
selectionMenuListWidget = new QListWidget;
QVBoxLayout *vBoxLayout = new QVBoxLayout;
vBoxLayout->addWidget(addButton);
vBoxLayout->addStretch();
vBoxLayout->addWidget(removeButton);
vBoxLayout->addStretch();
vBoxLayout->addWidget(okButton);
vBoxLayout->addStretch();
vBoxLayout->addWidget(backButton);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(supplyMenuListWidget);
mainLayout->addLayout(vBoxLayout);
mainLayout->addWidget(selectionMenuListWidget);
setLayout(mainLayout);
//setWindowtitle(“select menu“);
connection();
//resize(400300);
}
void ChooseMenu::readMenu()
{
QFile file(“gettabledata.txt“);
file.open(QIODevice::ReadOnly);
QTextStream in(&file);
while (!in.atEnd())
{
QString str = in.readLine(100);
(*menuList)< }
}
void ChooseMenu::writeSelectedMenus()
{
//write the selected menus to the file--selectedmenus.txt
QFile file(“selectedmenus.txt“);
file.open(QIODevice::WriteOnly);
QTextStream out(&file);
//flag which room is sent to payed
out<windowtitle()+“\n“;
int rowNum = selectionMenuListWidget->count();
int i = 0;
for (i;i {
QListWidgetItem *item=selectionMenuListWidget->item(i);
out<text()+“\n“;
}
file.close();
//send the data
/*pthread_t pid;
pthread_create(&pidNULLsend_selected_menusNULL);
sleep(10);
if(0 !=pthread_cancel(pid))
{
printf(“Can‘t cancel the sendselectedmenus thread\n“);
}*/
//clear the selectedmenus.txt
}
void ChooseMenu::addSlot()
{
QListWidgetItem *item = supplyMenuListWidget->currentItem();
selectionMenuListWidget->addItem(item->text());
//selectionMenuListWidget->addItem(“item“);
//update();
}
/*void ChooseMenu::addSlot(QListWidgetItem *item)
{
//QListWidgetItem *item = supplyMenuListWidget->cur
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 91 2010-06-28 21:23 big-project-late\client\gettabledata.txt
文件 6439 2010-06-27 18:02 big-project-late\client\choosemenu.cpp
文件 27 2010-06-28 21:23 big-project-late\client\selectedmenus.txt
文件 854 2010-06-27 17:59 big-project-late\client\choosemenu.h
文件 178940 2010-06-28 19:24 big-project-late\client\moc_openroom.o
文件 175012 2010-06-28 19:24 big-project-late\client\main.o
文件 9859 2010-06-27 11:58 big-project-late\client\openroom.cpp
文件 8612 2010-06-23 19:56 big-project-late\client\Makefile
文件 853970 2010-06-28 19:24 big-project-late\client\client
文件 359 2010-06-22 21:22 big-project-late\client\client.pro
文件 2770 2010-06-28 19:24 big-project-late\client\moc_openroom.cpp
文件 1872 2010-06-27 17:55 big-project-late\client\sendselectedmenus.h
文件 211652 2010-06-28 19:24 big-project-late\client\choosemenu.o
文件 584 2010-06-27 17:56 big-project-late\client\main.cpp
文件 1280 2010-06-25 21:19 big-project-late\client\openroom.h
文件 202896 2010-06-28 19:24 big-project-late\client\openroom.o
文件 2246 2010-06-28 19:24 big-project-late\client\moc_choosemenu.cpp
文件 1651 2010-06-27 16:31 big-project-late\client\gettabledata.h
文件 177912 2010-06-28 19:24 big-project-late\client\moc_choosemenu.o
文件 11952 2010-06-28 21:22 big-project-late\server\paymanagement.cpp
文件 2485 2010-06-28 21:28 big-project-late\server\moc_menumanagement.cpp
文件 81371 2010-06-28 21:28 big-project-late\server\server
文件 385 2010-06-21 17:51 big-project-late\server\server.pro
文件 91 2010-06-28 21:28 big-project-late\server\tabledata.txt
文件 26204 2010-06-28 21:28 big-project-late\server\main.o
文件 972 2010-06-22 07:49 big-project-late\server\paymanagement.h
文件 9326 2010-06-28 21:27 big-project-late\server\getselectedmenusdata.h
文件 9113 2010-06-28 21:27 big-project-late\server\Makefile
文件 2108 2010-06-27 17:34 big-project-late\server\sendtabledata.h
文件 8416 2010-06-27 08:38 big-project-late\server\menumanagement.cpp
............此处省略16个文件信息
- 上一篇:欧姆龙PLC温度采集传感器为PT100
- 下一篇:prolog医疗诊断专家系统
评论
共有 条评论