Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Inconvenient Behaviour: QSqlTableModel.removeRow()
QtWS25 Last Chance

Inconvenient Behaviour: QSqlTableModel.removeRow()

Scheduled Pinned Locked Moved Language Bindings
3 Posts 2 Posters 2.4k 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.
  • E Offline
    E Offline
    engdarkman89
    wrote on last edited by
    #1

    Hi All,,

    After updating PyQt version 4.8.5 to 4.9.4, QSqlTableModel.removeRow() has the following behavior:

    • Return True.
    • verticalHeaderData changed to "!".
    • Row content erased (Record fields become blank in the QTableView)
    • Calling submitAll() works as expected.

    More Info:

    • I tried to install a fresh copy of Python v2.7 & PyQt v4.9.4 to another machine but the problem persist.
    • Downgrading the PyQt version to 4.8.5 seems to solve the problem.

    Code: (This is the exact code used for testing on both versions)
    @
    mw = QMainWindow()

    model = QSqlTableModel(None, connectionManager().getConnection())
    model.setTable("vouchertypes")
    model.setEditStrategy(model.OnManualSubmit)
    model.select()
    
    tv = QTableView(mw)
    tv.setModel(model)
    
    bt = QPushButton("Delete", mw)
    bt.clicked.connect(lambda: model.removeRow(tv.currentIndex().row()))
    mw.show()
    

    @

    • If some can help providing me a previous PyQt ver(4.9.1 or 4.9.2 or 4.9.3) this might solve the problem for the current time.

    Appreciate any kind of help.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You are not describing the actual change in behavior, nor what you percieve to be the problem.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        engdarkman89
        wrote on last edited by
        #3

        sorry Andre, i will try to explain better now.

        the problem is: Why calling QSqlTableModel.removeRow() erase the row content in the view and model. (so, calling record.field().value().toString() for the removed row --without calling submitAll()-- returns empty string for all fields.!!)

        doing so with PyQt v4.8.5 will keep the row contents untouched until i call submitAll() for actual deletion.

        Thanks for your patience.

        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