本文整理汇总了C++中QListWidget::clearSelection方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidget::clearSelection方法的具体用法?C++ QListWidget::clearSelection怎么用?C++ QListWidget::clearSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidget
的用法示例。
在下文中一共展示了QListWidget::clearSelection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveModule
void SettingsWidget::moveModule()
{
if (QToolButton *tB = qobject_cast<QToolButton *>(sender()))
{
const bool moveDown = tB->arrowType() == Qt::DownArrow;
const int idx = tB->property("idx").toInt();
QListWidget *mL = page2ModulesList[idx]->list;
int row = mL->currentRow();
if (row > -1)
{
QListWidgetItem *item = mL->takeItem(row);
mL->clearSelection();
if (moveDown)
++row;
else
--row;
mL->insertItem(row, item);
mL->setCurrentItem(item);
}
}
}
示例2: btnDeleteClicked
void CQReportDefinition::btnDeleteClicked()
{
QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage());
QListWidgetItem * pNewSelection = NULL;
int i, multipleSelection;
for (i = pList->count() - 1, multipleSelection = 0; 0 <= i; i--)
if (pList->item(i)->isSelected())
{
delete pList->takeItem(i);
if (!pNewSelection && i < pList->count())
{
pNewSelection = pList->item(i); // We select the next.
}
multipleSelection++;
}
if (multipleSelection == 0) return; // Nothing selected,
mChanged = true;
pList->clearSelection();
if (multipleSelection > 1) return;
// Only one item was select and we move the selection to the next
if (!pNewSelection && pList->count()) // We have removed item at the end.
pNewSelection = pList->item(pList->count() - 1);
// pNewSelection is NULL if the list is empty
if (pNewSelection)
{
pNewSelection->setSelected(true);
}
return;
}