Results 1 to 4 of 4

Thread: [not solved] QTableView with QSqlrelationaltable and foreign key

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default [not solved] QTableView with QSqlrelationaltable and foreign key

    Hi,
    here is the problem. I have 2 tables Person and Status, 2 views and a foreign key in Person to Status.
    If i add new status in Status Table and after i go to Person, with the QSqlrelationalDelegate i can choose the status i want.
    But if after i go back to Status view and add a new line Status, then i do :
    Qt Code:
    1. if (m_model->relationModel(m_foreign)) m_model->relationModel(m_foreign)->select();
    To copy to clipboard, switch view to plain text mode 
    To update the delegate, so i can see the new value in the combobox, but...when i click on it. The new line is added on Person Table BUT WITH EMPTY FOREIGN KEY but i see nothing on the View. So i suppose the combobox used in delegate doesn't send the good id but why ? I tried lot of things. I can add other person only if the status were added first in Person Status. If the status is once added after i added first person then it doesn't work.
    As there is no example that use 2 views and foreign key like this i don't know if it is possible doing it that way.
    If i restart program i can add person but last status as it is already in Status Table before i add first Person.
    Thanks for answer
    Last edited by archqt; 9th January 2011 at 14:55.

  2. #2
    Join Date
    Jan 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [not solved] QTableView with QSqlrelationaltable and foreign key

    With some tests, it seems that the delegate works fine. I try to look for another thing.

  3. #3
    Join Date
    Jan 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [not solved] QTableView with QSqlrelationaltable and foreign key

    I do some tests and i found that this line return false and i don't know why :
    Qt Code:
    1. sqlModel->setData(index,
    2. childModel->data(childModel->index(currentItem, childEditIndex), Qt::EditRole),
    3. Qt::EditRole);
    To copy to clipboard, switch view to plain text mode 
    But one thing strange is that there is also a beforeInsert(QSqlRecord&) signal ?
    Can anymore help me.
    Thanks

  4. #4
    Join Date
    Jan 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [not solved] QTableView with QSqlrelationaltable and foreign key

    It is an internal bug of Qt. So my advice don't use QSqlRelationalTableModel. Do your own

Similar Threads

  1. Replies: 3
    Last Post: 18th April 2014, 03:37
  2. Replies: 2
    Last Post: 21st January 2011, 17:12
  3. Replies: 0
    Last Post: 22nd April 2010, 13:18
  4. QTableView row/column count [SOLVED]
    By jano_alex_es in forum Newbie
    Replies: 2
    Last Post: 14th May 2009, 11:10
  5. Nullable foreign keys in QTableView
    By Banjo in forum Newbie
    Replies: 3
    Last Post: 31st January 2008, 22:07

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.