本文整理汇总了C++中Computer::setID方法的典型用法代码示例。如果您正苦于以下问题:C++ Computer::setID方法的具体用法?C++ Computer::setID怎么用?C++ Computer::setID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer::setID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getComputer
Computer ComputerRepository::getComputer(const unique_ptr<QSqlQuery> &query) {
Computer comp;
comp.setID(query->value("id").toInt());
comp.setName(query->value("name").toString().toStdString());
comp.setType(query->value("type").toString().toStdString());
comp.setBuildYear(query->value("build_year").toInt());
comp.setBuilt(query->value("built").toBool());
return comp;
}
示例2: if
vector<Computer> ComputerRepository::search(string input, string word) {
db.open();
vector<Computer> temp;
QString qinput = QString::fromStdString(input);
QString likeInput = "%" + qinput + "%";
QSqlQuery query;
if(word == "Name") {
query.prepare("SELECT * FROM Computers c WHERE c.Name LIKE :contains ORDER BY Name;");
} else if(word == "Build Year") {
query.prepare("SELECT * FROM Computers c WHERE c.BuildYear LIKE :contains ORDER BY Name");
} else if(word == "Type") {
query.prepare("SELECT * FROM Computers c WHERE c.Type LIKE :contains ORDER BY Name");
} else {
query.prepare("SELECT * FROM Computers c WHERE c.Built LIKE :contains ORDER BY Name");
}
query.bindValue(":contains",likeInput);
query.exec();
while(query.next()) {
Computer c;
c.setName(query.value("Name").toString().toStdString());
c.setBuildYear(query.value("BuildYear").toString().toStdString());
c.setType(query.value("Type").toString().toStdString());
c.setBuilt(query.value("Built").toInt());
c.setID(query.value("ID").toInt());
temp.push_back(c);
}
db.close();
return temp;
}
示例3: while
vector<Computer> ComputerRepository::getComputersFromScientist(Person scientist) {
db.open();
vector<Computer> temp;
QSqlQuery query;
query.prepare("SELECT * FROM Computers c JOIN Linker l ON l.c_ID = c.ID AND l.p_ID = ?");
query.addBindValue(scientist.getID());
query.exec();
while(query.next()) {
Computer c;
c.setName(query.value("Name").toString().toStdString());
c.setBuildYear(query.value("BuildYear").toString().toStdString());
c.setType(query.value("Type").toString().toStdString());
c.setBuilt(query.value("Built").toInt());
c.setID(query.value("ID").toInt());
temp.push_back(c);
}
db.close();
return temp;
}