How to set focus for disabled widget
-
Hi,
I have a qtreewidget which has couple of widget. For one of the widget on selecting it I'm executing following code for a reason
qWidgetObject->setEnabled(false);after executing the above line. Focus which previously there for that widget is moving to next widget in the tree. I understand that disabled widgets cannot have focus. But is there a way to set focus any way??
-
Hi,
I have a qtreewidget which has couple of widget. For one of the widget on selecting it I'm executing following code for a reason
qWidgetObject->setEnabled(false);after executing the above line. Focus which previously there for that widget is moving to next widget in the tree. I understand that disabled widgets cannot have focus. But is there a way to set focus any way??
@AbhiVarma said in How to set focus for disabled widget:
But is there a way to set focus any way??
You already answered by yourself: disabled widgets can't have focus.
-
Hi,
I have a qtreewidget which has couple of widget. For one of the widget on selecting it I'm executing following code for a reason
qWidgetObject->setEnabled(false);after executing the above line. Focus which previously there for that widget is moving to next widget in the tree. I understand that disabled widgets cannot have focus. But is there a way to set focus any way??
@AbhiVarma said in How to set focus for disabled widget:
Focus which previously there for that widget is moving to next widget in the tree
If you don't want any selection, I think you should set the selection mode to QAbstractItemView::SingleSelection
QAbstractItemView::SingleSelection 1
When the user selects an item, any already-selected item becomes unselected. It is possible for the user to deselect the selected item.Or if it doesn't work, reset the selection with:
QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
treeWidget->selectionModel()->clearSelection()