Results 1 to 3 of 3

Thread: QTableView Edit Focus

  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableView Edit Focus

    I have a table view in a form. When the user clicks the add button to add a new record, I would like to put the focus on the first column in the new record for editing, so the cursor should be there as soon as the user clicks the add button.

    I've gotten as far as adding the new record and getting the row selected, but I'm stuck on how to get the first column editable with the cursor in it.

    It works ok if you double click the first column for editing, but I would like the program to do that for the user.

    I tried this since the row is already selected by the program:
    Qt Code:
    1. QModelIndex index = ui->tvMemories->currentIndex();
    2. ui->tvMemories->edit(index);
    To copy to clipboard, switch view to plain text mode 
    Doesn't do what I need. Someone must have figured out how to do this already?
    Thanks for any ideas.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView Edit Focus

    Is the item editable ?
    and if yes,, what are the triggers that invoke editing ?

  3. #3
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableView Edit Focus

    Yes, if you double click in a cell on the selected row, you can edit it.
    The triggers are set to "all"
    ui->tvMemories->setEditTriggers(QAbstractItemView::AllEditTrigger s);

Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 19:06
  2. Replies: 2
    Last Post: 21st January 2011, 17:12
  3. Is there focus event for line edit?
    By vjsharma_30 in forum Qt Programming
    Replies: 6
    Last Post: 19th February 2010, 20:12
  4. QTableView - model / view pattern - layout, edit
    By vlastagf in forum Qt Programming
    Replies: 4
    Last Post: 1st August 2009, 22:42
  5. line edit focus
    By addu in forum Qt Programming
    Replies: 3
    Last Post: 16th July 2009, 15:39

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.