Results 1 to 6 of 6

Thread: How to focus on QTableView Item

  1. #1
    Join Date
    Mar 2011
    Posts
    45
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to focus on QTableView Item

    hi,
    hope u can help:
    i have QTableView *tableview and i insert a row to it by
    Qt Code:
    1. tableview->model()->insertRow(0);
    To copy to clipboard, switch view to plain text mode 
    Whereby the model is a custom model subclassed from QAbstractTableModel.
    Insertion works fine and one can edit the row-content by double-clicking on the freshly created row.

    Now, i want the inserted row (this is editable) to get the edit-focus immediately without having to double-click on it to edit it).
    how do i do that?
    thnx.

  2. #2
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to focus on QTableView Item

    I have no idea if this will work, but the first thing i would try - emit the signal item doubleclicked...
    Again - I don't know if this will work...

  3. #3
    Join Date
    Mar 2011
    Posts
    45
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to focus on QTableView Item

    well, i had written that my widget is a QTableView .. itemDoubleClicked() exists
    for QListWidget QTableWidget QTreeWidget.

    any other ideas ??


    Added after 5 minutes:


    the signal from QTableView that is emited when item is double clicked is
    doubleClicked(..).

    unfortunately this is protected. is there a way to emit this without having to subclass QTableView !?!?
    Last edited by kerim; 14th April 2011 at 08:07.

  4. #4
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to focus on QTableView Item

    My idea was - can u do
    Qt Code:
    1. emit this->itemDoubleClicked(the item u want to edit)
    To copy to clipboard, switch view to plain text mode 

    ...

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to focus on QTableView Item

    Is the public slot QAbstractItemView::edit() what you are looking for? Read the docs about also using setCurrentIndex() with it.

  6. #6
    Join Date
    Mar 2011
    Posts
    45
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to focus on QTableView Item

    thnx chris, thats it.

Similar Threads

  1. QTableView Edit Focus
    By waynew in forum Qt Programming
    Replies: 2
    Last Post: 16th August 2010, 12:24
  2. focus on a Item
    By peace_comp in forum Qt Programming
    Replies: 1
    Last Post: 6th July 2008, 17:52
  3. default on focus different item in messagebox?
    By gfunk in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2007, 05:54
  4. QGraphicsView and item focus
    By Micawber in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2007, 20:36
  5. Replies: 3
    Last Post: 7th November 2006, 08:35

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.