currentRowChanged (const QModelIndex & current, const QModelIndex & previous)
// Обработка изменения засветки в списке конечных записейconnect(recordView->selectionModel(), SIGNAL(currentChanged (const QModelIndex&, const QModelIndex&)), this, SLOT(onSelectionRecordChanged(const QModelIndex&, const QModelIndex&)));
// Действия при изменении местоположения указателя в списке конечных записейvoid RecordTableScreen::onSelectionRecordChanged(const QModelIndex &indexCurrent, const QModelIndex &indexPrevious){ qDebug() << "RecordTableScreen::onSelectionRecordChanged()"; qDebug() << "Current index row() " << indexCurrent.row() << " isValid() " << indexCurrent.isValid(); qDebug() << "Previous index row() " << indexPrevious.row() << " isValid() " << indexPrevious.isValid();}
[DBG] RecordTableScreen::onSelectionRecordChanged() [DBG] Current index row() 0 isValid() true [DBG] Previous index row() -1 isValid() false[DBG] RecordTableScreen::onSelectionRecordChanged() [DBG] Current index row() 4 isValid() true [DBG] Previous index row() 0 isValid() true
C++ (Qt)MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ ui.setupUi(this); fsm = new QFileSystemModel; fsm->setRootPath("."); ism = new QItemSelectionModel(fsm, ui.listView); ui.listView->setModel(fsm); ui.listView->setSelectionModel(ism); ui.listView->setRootIndex(fsm->index(".")); connect(ism, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(rowChanged(QModelIndex,QModelIndex)));} void MainWindow::rowChanged(const QModelIndex &newIndex, const QModelIndex &oldIndex){ qDebug() << "old" << oldIndex.data() << "new" << newIndex.data();}
pushButton->setFocus();