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

QDataWidgetMapper loses the current model index

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 4.7.3
    • Widgets: Itemviews
    • None
    • 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

        1. MapperBug.zip
          5 kB
          Filippo Santovito
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            stephen.kelly Stephen Kelly (Unused account) (Inactive)
            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