Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I unset or change a relation on a QSqlRelationalTableModel?

How can I unset or change a relation on a QSqlRelationalTableModel?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jonathan
    wrote on last edited by
    #1

    I can use QSqlRelationalTableModel::setRelation (int column, const QSqlRelation & relation) to set a relationship.

    However I want to be able to change the column that is displayed from the "foreign" table.

    Calling setRelation a second time with a different QSqlRelation doesn't seem to have an effect, and there appears to be no "unsetRelation".

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      To unset the relation I would try:
      @model->setRelation(column, QSqlRelation());@

      For the other issue you might want to look into "edit strategies":http://doc.trolltech.com/latest/qsqltablemodel.html#EditStrategy-enum

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jonathan
        wrote on last edited by
        #3

        After much guessing and testing I discovered I needed to call

        @QSqlRelationalTableModel::setModel()@

        after I set or change the relationship.

        @QTableView::setItemDelegate()@ also now works properly.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved