Results 1 to 1 of 1

Thread: Insert a row to a QSqlTableModel with prefilled columns

  1. #1
    Join Date
    Dec 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Insert a row to a QSqlTableModel with prefilled columns

    Hi,

    I have a QSqlTableModel. I use Blanchette's method to insert a new row:
    Qt Code:
    1. int row = myModel->rowCount();
    2. myModel->insertRow(row);
    3. QModelIndex index = myModel->index(row, 1);
    4. myTableView->setCurrentIndex(index);
    5. myTableView->edit(index);
    To copy to clipboard, switch view to plain text mode 

    I would like to fill one of the columns of myModel (which is hidden in the View) with a value (which depends on a selection on another table). Is that possible?

    Thanks in advance.

    I reply to myself, as I found a way:

    Qt Code:
    1. myModel->setData(myModel->index(row,1), value);
    To copy to clipboard, switch view to plain text mode 
    Last edited by zeb; 9th December 2010 at 15:53.

Similar Threads

  1. Replies: 0
    Last Post: 17th September 2010, 13:19
  2. Trouble with "INSERT" by QSqlTableModel
    By AD in forum Qt Programming
    Replies: 12
    Last Post: 10th November 2008, 09:21
  3. Replies: 8
    Last Post: 14th August 2008, 16:48
  4. Moving columns/hiding columns in QTreeView
    By yogeshm02 in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2007, 17:22
  5. Reorder the columns in QSqlTableModel/QTableView?
    By gfunk in forum Qt Programming
    Replies: 2
    Last Post: 18th July 2006, 00:30

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.