本文整理汇总了C++中WTable::rowCount方法的典型用法代码示例。如果您正苦于以下问题:C++ WTable::rowCount方法的具体用法?C++ WTable::rowCount怎么用?C++ WTable::rowCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WTable
的用法示例。
在下文中一共展示了WTable::rowCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void HighScoresWidget::update()
{
clear();
new WText("<h2>Hall of fame</h2>", this);
int ranking = session_->findRanking();
std::string yourScore;
if (ranking == 1)
yourScore = "Congratulations! You are currently leading the pack.";
else {
yourScore = "You are currently ranked number "
+ boost::lexical_cast<std::string>(ranking)
+ ". Almost there !";
}
WText *score = new WText("<p>" + yourScore + "</p>", this);
score->addStyleClass("score");
std::vector<User> top = session_->topUsers(20);
WTable *table = new WTable(this);
new WText("Rank", table->elementAt(0, 0));
new WText("User", table->elementAt(0, 1));
new WText("Games", table->elementAt(0, 2));
new WText("Score", table->elementAt(0, 3));
new WText("Last game", table->elementAt(0, 4));
table->setHeaderCount(1);
int formerScore = -1;
int rank = 0;
for (unsigned i = 0; i < top.size(); i++) {
User u = top[i];
if (u.score != formerScore) {
formerScore = u.score;
++rank;
}
int row = table->rowCount();
new WText(boost::lexical_cast<std::string>(rank),
table->elementAt(row, 0));
new WText(u.name, table->elementAt(row, 1));
new WText(boost::lexical_cast<std::string>(u.gamesPlayed),
table->elementAt(row, 2));
new WText(boost::lexical_cast<std::string>(u.score),
table->elementAt(row, 3));
if (!u.lastGame.isNull())
new WText(u.lastGame.timeTo(WDateTime::currentDateTime())
+ " ago", table->elementAt(row, 4));
else
new WText("---", table->elementAt(row, 4));
if (session_->login().loggedIn() && session_->userName() == u.name)
table->rowAt(row)->setId("self");
}
WText *fineprint = new WText(tr("highscore.info"), this);
fineprint->addStyleClass("fineprint");
}