QListWidget myList;connect(&myList, SIGNAL(currentItemChanged (QListWidgetItem *, QListWidgetItem *)), this, SLOT(MySelectedChanged(QListWidgetItem *, QListWidgetItem *)));//---MySelectedChanged(QListWidgetItem * current, QListWidgetItem * previous){ myList.setCurrentItem(previous); //до здравствует рекурсия!!!!}
MySelectedChanged(QListWidgetItem * current, QListWidgetItem * previous){ myList.blockSignals(true); myList.setCurrentItem(previous); //до здравствует рекурсия!!!! myList.blockSignals(false);}
C++ (Qt) void restoreCurrent(){ myList.setCurrentRow( myList.property( "current" ).toInt() ); myList.setProperty( "current", -1 );} MySelectedChanged(QListWidgetItem * current, QListWidgetItem * previous){ if( !previous || myList.property( "current" ).toInt() != -1 ) return; myList.setProperty( "current", myList.row( previous ) ); QTimer::singleShot( 0, this, SLOT( restoreCurrent() ) );}
C++ (Qt)void YourListView::currentChanged( const QModelIndex & current, const QModelIndex & previous ){ if( current.row() == 2 && QMessageBox::question() != QMessageBox::Yes ) return; QListWidget::currentChanged( current, previous );}
if( current.row() == 2