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. QTableView Editor closes after losing focus
Forum Updated to NodeBB v4.3 + New Features

QTableView Editor closes after losing focus

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 2.0k Views 3 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.
  • S Offline
    S Offline
    Sebastian
    wrote on last edited by
    #1

    Dear friends,

    I have a QTableview which have components on the cell like QLineEdit ,QComboBox, QCheckBox. So What I actually i wanted to do achieve like suppose i am entering some values in my QLineEdit then the editor is open after that I press Alt+Tab to open another application.when i came back on the QLineEdit(table) then the editor is close so i can not write any more untill unless i click the QlineEdit again.

    So basicly i want to achieve that QTableView should work like Excel works.When We switch using ALT+Tab and again i came back on QLineEdit the editor should be open and i can write until unless i move to the next cell.

    Please suggest me some ideas how can we achieve this or some example or some link .
    Thanks in Advance

    raven-worxR 1 Reply Last reply
    0
    • S Sebastian

      Dear friends,

      I have a QTableview which have components on the cell like QLineEdit ,QComboBox, QCheckBox. So What I actually i wanted to do achieve like suppose i am entering some values in my QLineEdit then the editor is open after that I press Alt+Tab to open another application.when i came back on the QLineEdit(table) then the editor is close so i can not write any more untill unless i click the QlineEdit again.

      So basicly i want to achieve that QTableView should work like Excel works.When We switch using ALT+Tab and again i came back on QLineEdit the editor should be open and i can write until unless i move to the next cell.

      Please suggest me some ideas how can we achieve this or some example or some link .
      Thanks in Advance

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Sebastian
      by default the editor is closed on focus-out.
      To overcome this, you can subclass QStyledItemDelegate and reimplement editorEvent() and simply return true in case of an focusout event.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      J 1 Reply Last reply
      3
      • S Offline
        S Offline
        Sebastian
        wrote on last edited by
        #3

        @raven-worx
        i have a class inherited from QStyledItemDelegate and re implemented the editorEvent() and return the true when event type is focus out. My problem is now like when we press the ALT+Tab and change to the another application.In that case focus out event never comes. I tried to find the reason may be the editor is deleted.

        Is there anyway should i try ???

        raven-worxR 1 Reply Last reply
        0
        • S Sebastian

          @raven-worx
          i have a class inherited from QStyledItemDelegate and re implemented the editorEvent() and return the true when event type is focus out. My problem is now like when we press the ALT+Tab and change to the another application.In that case focus out event never comes. I tried to find the reason may be the editor is deleted.

          Is there anyway should i try ???

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @Sebastian
          also filter the TAB/BACKTAB key press events.
          See this -> check every case where the closeEditor() signal is emitted.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          2
          • raven-worxR raven-worx

            @Sebastian
            by default the editor is closed on focus-out.
            To overcome this, you can subclass QStyledItemDelegate and reimplement editorEvent() and simply return true in case of an focusout event.

            J Offline
            J Offline
            jspanchu
            wrote on last edited by
            #5

            @raven-worx I think you mean eventFilter() instead of editorEvent()

            Pl45m4P 1 Reply Last reply
            0
            • J jspanchu

              @raven-worx I think you mean eventFilter() instead of editorEvent()

              Pl45m4P Online
              Pl45m4P Online
              Pl45m4
              wrote on last edited by
              #6

              @jspanchu

              No the code @raven-worx shows, is correct.


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              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