Hi hasmik!
The solution is to use the item view's selection model. The automatic enabling/disabling of the button can be achieved with a slot which will be connected to the selection model's selectionChanged signal.
MyDialog
::MyDialog(QWidget* parent
){
connect(itemView->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&))
,this,SLOT(onSelectionChanged()));
}
MyDialog::onSelectionChanged()
{
btnOk->setEnabled(itemView->selectionModel()->hasSelection());
}
MyDialog::MyDialog(QWidget* parent)
: QDialog(parent)
{
connect(itemView->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&))
,this,SLOT(onSelectionChanged()));
}
MyDialog::onSelectionChanged()
{
btnOk->setEnabled(itemView->selectionModel()->hasSelection());
}
To copy to clipboard, switch view to plain text mode
Bookmarks