Results 1 to 2 of 2

Thread: QTableView & QSqlRelationalTableModel

  1. #1
    Join Date
    Mar 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy QTableView & QSqlRelationalTableModel

    I have the following code. Only first of those relations have default value in combobox in the tableview in lisaa function. Only difference between those relations is, "prosentti" is integer, and "rooli" is text. I'm using SQLITE backend.

    I need to have a default value also in the second, "rooli", relation. But no go.

    Constructor:

    Qt Code:
    1. model->setTable("tili");
    2. model->setRelation(3, QSqlRelation("alv", "id", "prosentti"));
    3. model->setRelation(4, QSqlRelation("vast", "id", "rooli"));
    4. model->select();
    5.  
    6. tiliView->setModel(model);
    7. tiliView->setItemDelegate(new QSqlRelationalDelegate(tiliView));
    To copy to clipboard, switch view to plain text mode 

    Lisaa:

    Qt Code:
    1. void TiliWindow::lisaa()
    2. {
    3. int r = model->rowCount();
    4. model->insertRows(r, 1);
    5. QModelIndex index = model->index(r,1);
    6. tiliView->setCurrentIndex(index);
    7.  
    8. tiliView->edit(index);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTableView & QSqlRelationalTableModel

    Did you manage to solve the problem yet? I'm pretty sure debugging through QSqlRelationalDelegate::createEditor() would help (especially the line which sets the model column for the combo box).
    J-P Nurmi

Similar Threads

  1. Set height of QTableView to fit exact number of rows.
    By Ben.Hines in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2019, 01:49
  2. QTableView sorting
    By gabriels in forum Qt Programming
    Replies: 11
    Last Post: 6th October 2010, 17:13
  3. QTableView currentChanged <> selecting header
    By Everall in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2009, 08:24
  4. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42
  5. Multi-line messages in QTableView
    By Conel in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2006, 13:49

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.