2 Star 0 Fork 0

SmartFridge/fridge_terminal

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
dishrecommendunit.cpp 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
#include "dishrecommendunit.h"
#include "ui_dishrecommendunit.h"
#include "dishitem.h"
#include <QToolButton>
#include <dishdetail.h>
DishRecommendUnit::DishRecommendUnit(QWidget *parent,QString title,QList<Dish>* dishList) :
QWidget(parent),
ui(new Ui::DishRecommendUnit),
title(title),
dishList(dishList)
{
ui->setupUi(this);
ui->lable_title->setText(ui->lable_title->text()+title);
for(int i = ui->stackedWidget->count(); i >= 0; i--)
{
QWidget* widget = ui->stackedWidget->widget(i);
ui->stackedWidget->removeWidget(widget);
widget->deleteLater();
}
for(int i=0;i<dishList->count();i++)
{
Dish aDish = dishList->at(i);
DishItem* dishItem = new DishItem(this,aDish.id,aDish.name,aDish.material,aDish.detail,aDish.pic,aDish.type);
ui->stackedWidget->insertWidget(i,dishItem);
}
int totalIndex = ui->stackedWidget->count();
// qDebug()<<totalIndex;
ui->stackedWidget->setCurrentIndex(0);
connect(ui->btn_after,&QToolButton::clicked,[=](){
int current = ui->stackedWidget->currentIndex();
current++;
if(current==totalIndex)
{
current = 0;
}
// qDebug()<<current;
ui->stackedWidget->setCurrentIndex(current);
});
connect(ui->btn_before,&QToolButton::clicked,[=](){
int current = ui->stackedWidget->currentIndex();
current--;
if(current==-1)
{
current = totalIndex-1;
}
// qDebug()<<current;
ui->stackedWidget->setCurrentIndex(current);
});
}
DishRecommendUnit::~DishRecommendUnit()
{
delete ui;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/smart-ice-box/fridge_terminal.git
git@gitee.com:smart-ice-box/fridge_terminal.git
smart-ice-box
fridge_terminal
fridge_terminal
master

搜索帮助