本文整理汇总了C++中ListWidget::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ ListWidget::addItem方法的具体用法?C++ ListWidget::addItem怎么用?C++ ListWidget::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListWidget
的用法示例。
在下文中一共展示了ListWidget::addItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onNewPlayerWithName
void OptionsScreenPlayers::onNewPlayerWithName(const stringw& newName)
{
ListWidget* players = this->getWidget<ListWidget>("players");
if (players != NULL)
{
core::stringc newNameC(newName.c_str());
players->addItem( newNameC.c_str(), translations->fribidize(newName) );
}
}
示例2: addTracks
/** Updates the list of tracks shown.
*/
void GPInfoScreen::addTracks()
{
const std::vector<std::string> tracks = m_gp.getTrackNames();
ListWidget *list = getWidget<ListWidget>("tracks");
list->clear();
for (unsigned int i = 0; i < (unsigned int)tracks.size(); i++)
{
const Track *track = track_manager->getTrack(tracks[i]);
std::string s = StringUtils::toString(i);
list->addItem(s, translations->fribidize(track->getName()));
}
} // addTracks
示例3: refreshPlayerList
/** Refreshes the list of players.
*/
bool OptionsScreenPlayers::refreshPlayerList()
{
ListWidget* players = this->getWidget<ListWidget>("players");
if (players == NULL) return false;
// Get rid of previous
players->clear();
// Rebuild it
const int player_amount = PlayerManager::get()->getNumPlayers();
for (int i = 0; i < player_amount; i++)
{
// FIXME: Using a truncated ASCII string for internal ID. Let's cross
// our fingers and hope no one enters two player names that,
// when stripped down to ASCII, give the same identifier...
const PlayerProfile *player = PlayerManager::get()->getPlayer(i);
players->addItem(
core::stringc(player->getName().c_str()).c_str(),
translations->fribidize(player->getName()));
}
return true;
}
示例4: init
void StoryModeLobbyScreen::init()
{
Screen::init();
CheckBoxWidget* cb = getWidget<CheckBoxWidget>("rememberme");
cb->setState(false);
ListWidget* list = getWidget<ListWidget>("gameslots");
list->clear();
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
if (UserConfigParams::m_default_player.toString().size() > 0)
{
for (int n=0; n<players.size(); n++)
{
if (players[n].getName() == UserConfigParams::m_default_player.toString())
{
unlock_manager->setCurrentSlot(players[n].getUniqueID());
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
return;
}
}
}
for (int n=0; n<players.size(); n++)
{
if (players[n].isGuestAccount()) continue;
// FIXME: we're using a trunacted ascii version of the player name as
// identifier, let's hope this causes no issues...
list->addItem(core::stringc(players[n].getName().c_str()).c_str(),
players[n].getName() );
}
list->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
list->setSelectionID(0);
} // init