本文整理汇总了C++中QListView::currentIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ QListView::currentIndex方法的具体用法?C++ QListView::currentIndex怎么用?C++ QListView::currentIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListView
的用法示例。
在下文中一共展示了QListView::currentIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCOMPARE
void tst_QFontDialog::task256466_wrongStyle()
{
QFontDatabase fdb;
FriendlyFontDialog dialog;
QListView *familyList = reinterpret_cast<QListView*>(dialog.d_func()->familyList);
QListView *styleList = reinterpret_cast<QListView*>(dialog.d_func()->styleList);
QListView *sizeList = reinterpret_cast<QListView*>(dialog.d_func()->sizeList);
for (int i = 0; i < familyList->model()->rowCount(); ++i) {
QModelIndex currentFamily = familyList->model()->index(i, 0);
familyList->setCurrentIndex(currentFamily);
const QFont current = dialog.currentFont(),
expected = fdb.font(currentFamily.data().toString(),
styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt());
QCOMPARE(current.family(), expected.family());
QCOMPARE(current.style(), expected.style());
QCOMPARE(current.pointSizeF(), expected.pointSizeF());
}
}
示例2: eventFilter
bool LocationManagementEditHelper::eventFilter(QObject *obj, QEvent *ev)
{
QListView *view = qobject_cast<QListView*>(obj);
if(!view)
return false;
if(ev->type() == QEvent::Show) {
last_uuid = 0;
qDebug() << "EventFilter: " << last_uuid;
}
if(ev->type() == QEvent::KeyPress) {
QKeyEvent *keyEv = (QKeyEvent*) ev;
if(keyEv->key() == Qt::Key_Return) {
handleActivation(view->currentIndex());
view->hide();
return true;
}
}
return false;
}
示例3: mapChanged
// Type: 0 = static, 1 = mission
void HWMapContainer::mapChanged(const QModelIndex & map, int type, const QModelIndex & old)
{
QListView * mapList;
if (type == 0) mapList = staticMapList;
else if (type == 1) mapList = missionMapList;
else return;
// Make sure it is a valid index
if (!map.isValid())
{
if (old.isValid())
{
mapList->setCurrentIndex(old);
mapList->scrollTo(old);
}
else
{
m_mapInfo.type = MapModel::Invalid;
updatePreview();
}
return;
}
// If map changed, update list selection
if (mapList->currentIndex() != map)
{
mapList->setCurrentIndex(map);
mapList->scrollTo(map);
}
if (map.data(Qt::UserRole + 1).canConvert<MapModel::MapInfo>())
setMapInfo(map.data(Qt::UserRole + 1).value<MapModel::MapInfo>());
else
Q_ASSERT(false); // Houston, we have a problem.
}
示例4: deleteSelected
void EmoticonViewer::deleteSelected()
{
QListView *view = _ui->listView;
view->model()->removeRow(view->currentIndex().row());
}
示例5: accept
void EmoticonViewer::accept()
{
QListView *view = _ui->listView;
emit hasTextToInsert(view->model()->data(view->currentIndex()).toString());
close();
}