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

submitAll fail if it is send from a QAction but not from a QPushButton

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Cannot Reproduce
    • Affects Version/s: 4.6.0
    • Fix Version/s: None
    • Component/s: SQL Support
    • Labels:
      None
    • Environment:
      Windows 7

      Description

      In the code below if on_pushButton_clicked() is call from the QToolButton of the toolbar (SIGNAL(triggered())), submitAll fail. If it is call from a push button (SIGNAL(clicked())) it works.

      C++
      class MainWindow : public QMainWindow {
          Q_OBJECT
      
          QSqlTableModel* modelDossiers;
          QDataWidgetMapper *mapper;
      public:
          MainWindow(QWidget *parent = 0);
          ~MainWindow();
      private slots:
          void on_pushButton_clicked();
      private:
          Ui::MainWindow *ui;
      };
      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
          QSqlDatabase m_dbSQLite = QSqlDatabase::addDatabase("QSQLITE");
          m_dbSQLite.setDatabaseName("c:/Dev/Bels2/Bels2/Datas/Bels.sqlite");
          if(m_dbSQLite.open())
          {
              modelDossiers = new QSqlTableModel ();
              modelDossiers->setTable("Patients");
              modelDossiers->setFilter(QString("ID = %1").arg(3742));
              modelDossiers->setEditStrategy(QSqlTableModel::OnManualSubmit);
              modelDossiers->select();
      
              mapper = new QDataWidgetMapper ();
      
              mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
              mapper->setModel(modelDossiers);
              mapper->addMapping(ui->lineEdit, modelDossiers->fieldIndex("Name"));
              mapper->toFirst();
      
              ui->mainToolBar->addAction(tr("Valid"), this, SLOT(on_pushButton_clicked()));
           }
      
      }
      
      void MainWindow::on_pushButton_clicked()
      {
          if(modelDossiers->submitAll())
              qDebug () << "Submit";
      }
      
      

        Attachments

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

          Activity

            People

            Assignee:
            mgoddard Michael Goddard (closed Nokia identity) (Inactive)
            Reporter:
            phildu44 GRAIN
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes