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

QDataWidgetMapper loses the current model index

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Incomplete
    • Affects Version/s: 4.7.3
    • Fix Version/s: None
    • Component/s: Widgets: Itemviews
    • Labels:
      None
    • Environment:
      qt 4.7.3 windows/mingw

      Description

      When a widget mapped via QDataWidgetMapper to a QSqlTableModel model loses the focus and a not mapped widget gets the focus
      if the mapper uses the AutoSubmit policy then the mapper loses the current model index.
      This happens only when the model is a QSqlTableModel. If the model is a QStandardItemModel everything work fine.

      I've attached a small project to demonstrate this bug. the test button runs this code:

      void MainWindow::on_run_test_clicked()
      {
          mapper->setCurrentIndex(0);
      
          this->ui->tableView->setFocus(Qt::MouseFocusReason);
          this->ui->tableView->selectionModel()->select(this->ui->tableView->model()->index(0,0), QItemSelectionModel::ClearAndSelect);
          this->ui->dateTimeEdit->setFocus(Qt::MouseFocusReason);
          this->ui->lineEdit->setFocus(Qt::MouseFocusReason);
      
          this->ui->test->setText(QString("this->mapper->currentIndex() == %1").arg(this->mapper->currentIndex()));
      }
      

      comment line mainwindow.cpp:12 to run the test using QStandardItemModel.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            stephen.kelly Stephen Kelly (Unused account) (Inactive)
            Reporter:
            mementomori Filippo Santovito
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes