本文整理汇总了C++中ListBox::setSelected方法的典型用法代码示例。如果您正苦于以下问题:C++ ListBox::setSelected方法的具体用法?C++ ListBox::setSelected怎么用?C++ ListBox::setSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListBox
的用法示例。
在下文中一共展示了ListBox::setSelected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Window
ChangeSalary::ChangeSalary(Widget* p, unsigned int salary)
: Window( p, Rect(), "" ), __INIT_IMPL(ChangeSalaryWindow)
{
setupUI( ":/gui/changesalary.gui");
setCenter( parent()->center() );
_dfunc()->newSalary = salary;
ListBox* lbxTitles;
GET_WIDGET_FROM_UI( lbxTitles )
if( lbxTitles )
{
world::GovernorRanks ranks = world::EmpireHelper::ranks();
for( auto rank : ranks )
{
std::string salaryStr = _( "##" + rank.rankName + "_salary##" );
ListBoxItem& item = lbxTitles->addItem( salaryStr + " " + utils::i2str( rank.salary ) );
item.setTag( rank.salary );
if( rank.salary == salary )
{
lbxTitles->setSelected( lbxTitles->itemsCount() - 1 );
}
}
}
INIT_WIDGET_FROM_UI( PushButton*, btnCancel )
INIT_WIDGET_FROM_UI( PushButton*, btnOk )
CONNECT( btnCancel, onClicked(), this, ChangeSalary::deleteLater );
CONNECT( btnOk, onClicked(), _dfunc().data(), Impl::setNewSalary );
CONNECT( btnOk, onClicked(), this, ChangeSalary::deleteLater );
CONNECT( lbxTitles, onItemSelected(), _dfunc().data(), Impl::resolveSalaryChange );
}
示例2: updateSelection
void DeprecatedRenderSelect::updateSelection()
{
const Vector<HTMLElement*>& listItems = static_cast<HTMLSelectElement*>(node())->listItems();
int i;
// if multi-select, we select only the new selected index
ListBox *listBox = static_cast<ListBox*>(m_widget);
int j = 0;
for (i = 0; i < int(listItems.size()); i++) {
listBox->setSelected(j, listItems[i]->hasTagName(optionTag) &&
static_cast<HTMLOptionElement*>(listItems[i])->selected());
if (listItems[i]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
++j;
}
m_selectionChanged = false;
}