Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to set focus for disabled widget
Forum Updated to NodeBB v4.3 + New Features

How to set focus for disabled widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 318 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AbhiVarma
    wrote on last edited by
    #1

    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??

    jsulmJ M 2 Replies Last reply
    0
    • A AbhiVarma

      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??

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A AbhiVarma

        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??

        M Offline
        M Offline
        mpergand
        wrote on last edited by mpergand
        #3

        @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()

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved