Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-12215

Show and hide column with QTableView does not work properly with QSqlTableModel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • Some future release
    • 4.6.3
    • Widgets: Itemviews
    • None
    • kubuntu 10.04
      gcc v4.4.3
      PostgreSQL v8.4.4

    Description

      See the attached test case that reproduces the problem (see file main_window.cpp to set the SQL context).

      Context :

      • a QSqlTableModel object that works on two different tables (one active at a time of course)
      • a QTableView on that model
      • when "table2" is selected we hide an inner column (not the first or last one) with QTableView::hideColumn()
      • when "table1" is selected we show back the previously hidden column with QTableView::showColumn()

      Steps :
      0. At loading "view1" is showed with columns "id, data" -> OK
      1. Select "view2" in the combo box, columns "id, data0" are displayed, but not the "data" column (it was hidden with hideColumn()) -> OK
      2. Select back "view1" in the combo box, only column "id" is erroneously displayed, however showColumn() was called for column "data" -> KO

      Note that if show/hide column is performed before QSqlTableModel::select() then it surprisingly works.
      A possible fix is to call begin/endRemoveColumns() inside the implementation of QSqlTableModel::select().

      Attachments

        1. qtbug_tableview.zip
          3 kB
          Hugues Delorme
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dedietri Gabriel de Dietrich (drgvond)
            cerf Hugues Delorme
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes