Results 1 to 2 of 2

Thread: closeEditor on a QTreeWidgetItem

  1. #1
    Join Date
    Sep 2006
    Posts
    46
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default closeEditor on a QTreeWidgetItem

    After reading through the docs I found

    closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint )

    but it appears I would need a custom model in order to implement this call to close the editor on the tree item in edit mode.
    My problem is when I add a new item to a subclassed QTreeWidget I call
    Qt Code:
    1. QTreeWidget::editItem(newItem);
    To copy to clipboard, switch view to plain text mode 
    to allow an edit of the item that was just inserted.

    Now if I use a context menu to add another item the mouse click will cause a close editor event and the next new item will be selected and put into edit mode and all is fine. The problem arises when you use a toolbar, or menu action to add the item it will not close the first item's edit mode and the newly added item will not produce the desired behavior.

    My questions is there anyway to force a close editor event so the newly entered item will be able to call edit? Or is there another way to produce the desired results?

  2. #2
    Join Date
    Sep 2006
    Posts
    46
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: closeEditor on a QTreeWidgetItem

    If anyone is interested you can force a closEditor event in this situation with a

    Qt Code:
    1. setItemExpanded(oldItem,true);
    To copy to clipboard, switch view to plain text mode 
    Where oldItem is the previously created item left in edit mode.

    Not very clean, but works for now none the less.

Similar Threads

  1. QTreeWidgetItem swap or move up one level problem
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2006, 18:34
  2. From extends QTreeWidgetItem emit signal?
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 19th May 2006, 14:54
  3. Model-Views: How to obtain QTreeWidgetItem from QModelIndex
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 8th April 2006, 20:37
  4. QTreeWidgetItem
    By Sarma in forum Qt Programming
    Replies: 1
    Last Post: 6th April 2006, 19:52
  5. enabling a QTreeWidgetItem as false
    By Kapil in forum Newbie
    Replies: 2
    Last Post: 3rd March 2006, 07:32

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.