本文整理汇总了C++中Food::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ Food::setName方法的具体用法?C++ Food::setName怎么用?C++ Food::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Food
的用法示例。
在下文中一共展示了Food::setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseElement
Food Food::parseElement( const QDomElement &element, bool *ok )
{
if ( element.tagName() != "food" ) {
qCritical() << "Expected 'food', got '" <<element.tagName() << "'.";
if ( ok ) *ok = false;
return Food();
}
Food result = Food();
QDomNode n;
for( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) {
QDomElement e = n.toElement();
if ( e.tagName() == "name" ) {
result.setName( e.text() );
}
else if ( e.tagName() == "taste" ) {
result.setTaste( e.text() );
}
}
if ( ok ) *ok = true;
return result;
}
示例2: populateFoodList
void AdminWindow::populateFoodList()
{
listFood = new QListWidget();
QWidget *widget = new QWidget();
QVBoxLayout *layout = new QVBoxLayout();
QSqlQuery query;
query.prepare("SELECT * FROM Foods");
bool r = query.exec();
if(r == true)
{
while(query.next())
{
// qDebug()<<"Food Selected: "<<query.record().value("name").toString();
//======================
QListWidgetItem* item = new QListWidgetItem();
item->setSizeHint(QSize(0,60));
FoodRow *catagory = new FoodRow();
Food *food = new Food();
food->setName(query.record().value("Name").toString());
food->setCatagroy(query.record().value("Catagory").toString());
food->setPrice(query.record().value("Price").toFloat());
catagory->SetFood(food);
layout->addWidget(catagory);
connect(catagory, SIGNAL(signal_foodRemoved(QString)), this, SLOT(onFoodRemoved(QString)));
connect(catagory, SIGNAL(signal_foodEdited(Food*)), this, SLOT(onFoodEdited(Food*)));
}
widget->setLayout(layout);
ui->scrollArea_FoodAdd->setWidget(widget);
}
}