Results 1 to 11 of 11

Thread: ActiveFocus with TextEdit

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ActiveFocus with TextEdit

    The treeview has an editable delegate. So when I'm editing an item on the treeview and click an item in the listview, I would like the item which is in edit mode to loose focus.
    I meant I would like to change the edit mode to non-edit mode, if a user clicks on any other item on the qml page.

    Let me explain the scenario, I have buttons, a treeview and listview in the same screen. When I enable the item to be edited and start editing the item in the treeview by setting activeFocus, so that the keyboard key strokes are accepted by the textedit.

    Now if I click on some other button on the screen or any item in the listview without setting the activeFocus on the item I just clicked, the activeFocus of the item in the treeview isn't lost, this activeFocus loss is used to set the text and change the edit mode to non-edit mode.

    So currently i'm setting activeFocus explicitly on the item I clicked(i.e. button or item in the listview) other than the treeview item to disable the activeFocus on the treeview item.

    Is there a better way to shift activeFocus from the treeview item rather than configuring activeFocus on any other item which is clicked?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ActiveFocus with TextEdit

    I think I understand better now.

    - when click a button or a ListView entry, you want to stop editing mode on the tree view
    - you currently do that by tracking activeFocus in the tree view delegate

    What about this
    - add a method to your tree model that resets all "edit enabled" values
    - call that method when you want to stop editing
    - ignore anything focus related in QML

    I.e. instead of calling forceActiveFocus() in the list view delegate's mouse area you would then do something like
    Qt Code:
    1. treemodel.stopEditing()
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ActiveFocus with TextEdit

    Thanks anda_skoa for the suggestions..

    But then for every new item added I have to ensure that the method is called.

    Can you suggest if there exist another way to do so?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ActiveFocus with TextEdit

    Difficult.

    What you could try is a MouseArea that fills the whole window, sits below the tree view but above everything else.
    When it is clicked, it calls the reset method.
    It would also need to set propagateComposedEvents otherwise you can't click on anything below it.

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    volcano (28th June 2016)

  6. #5
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ActiveFocus with TextEdit

    Thanks anda_skoa.

    Will try out your suggestion.

Similar Threads

  1. Qml TextEdit
    By goli in forum Newbie
    Replies: 4
    Last Post: 28th April 2011, 14:37
  2. Table in TextEdit
    By Splatify in forum Newbie
    Replies: 1
    Last Post: 8th March 2011, 18:57
  3. textedit
    By limeir in forum Qt Programming
    Replies: 1
    Last Post: 13th July 2010, 10:27
  4. [B]tableWidget row,col to textEdit[B]
    By briang in forum Newbie
    Replies: 1
    Last Post: 6th November 2009, 04:22
  5. Printing from a textEdit
    By Nefastious in forum Newbie
    Replies: 2
    Last Post: 21st October 2009, 05:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.