本文整理汇总了C++中QSpinBox::stepDown方法的典型用法代码示例。如果您正苦于以下问题:C++ QSpinBox::stepDown方法的具体用法?C++ QSpinBox::stepDown怎么用?C++ QSpinBox::stepDown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSpinBox
的用法示例。
在下文中一共展示了QSpinBox::stepDown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uintEdit
void tst_QItemDelegate::uintEdit()
{
QListView view;
QStandardItemModel model;
{
QStandardItem *data=new QStandardItem;
data->setEditable(true);
data->setData(QVariant((uint)1), Qt::DisplayRole);
model.setItem(0, 0, data);
}
{
QStandardItem *data=new QStandardItem;
data->setEditable(true);
data->setData(QVariant((uint)1), Qt::DisplayRole);
model.setItem(1, 0, data);
}
view.setModel(&model);
view.setEditTriggers(QAbstractItemView::AllEditTriggers);
const QModelIndex firstCell = model.index(0, 0);
QCOMPARE(firstCell.data(Qt::DisplayRole).userType(), static_cast<int>(QMetaType::UInt));
view.selectionModel()->setCurrentIndex(model.index(0, 0), QItemSelectionModel::Select);
view.edit(firstCell);
QSpinBox *sb = view.findChild<QSpinBox*>();
QVERIFY(sb);
sb->stepUp();
// Select another index to trigger the end of editing.
const QModelIndex secondCell = model.index(1, 0);
view.selectionModel()->setCurrentIndex(secondCell, QItemSelectionModel::Select);
QCOMPARE(firstCell.data(Qt::DisplayRole).userType(), static_cast<int>(QMetaType::UInt));
QCOMPARE(firstCell.data(Qt::DisplayRole).toUInt(), static_cast<uint>(2));
view.edit(secondCell);
// The first spinbox is deleted with deleteLater, so it is still there.
QList<QSpinBox*> sbList = view.findChildren<QSpinBox*>();
QCOMPARE(sbList.size(), 2);
sb = sbList.at(1);
sb->stepDown(); // 1 -> 0
sb->stepDown(); // 0 (no effect)
sb->stepDown(); // 0 (no effect)
// Select another index to trigger the end of editing.
view.selectionModel()->setCurrentIndex(firstCell, QItemSelectionModel::Select);
QCOMPARE(secondCell.data(Qt::DisplayRole).userType(), static_cast<int>(QMetaType::UInt));
QCOMPARE(secondCell.data(Qt::DisplayRole).toUInt(), static_cast<uint>(0));
}