Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. no submit data with editable QComboBox

no submit data with editable QComboBox

Scheduled Pinned Locked Moved General and Desktop
qcomboboxeditablerelation
5 Posts 2 Posters 2.0k 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.
  • M Offline
    M Offline
    Mr. Kibu
    wrote on 23 Jun 2015, 20:29 last edited by
    #1

    Hello!

    I have got a problem with a editable combobox that is mapped with a QSqlRelationalTableModel.

    First is create the model and set the relation:

    mModelVoucherPos = new QSqlRelationalTableModel(this, ConnProjectDB::db());
    mModelVoucherPos->setTable("VoucherPos");
    mModelVoucherPos->setRelation(mModelVoucherPos->fieldIndex("CostCenterKey"), QSqlRelation("vCostCenter","CcKey","text"));
    

    Than I map the data with the QComboBox:

    mMapVoucherPos=new QDataWidgetMapper(this);
    mMapVoucherPos->setModel(mModelVoucherPos);
    mMapVoucherPos->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
    mMapVoucherPos->setItemDelegate(new QSqlRelationalDelegate(mMapVoucherPos));
    
    mMapVoucherPos->addMapping(ui->cbCostCenter,8);
    

    With "mMapVoucherPos->submit();" I submit the data to the QSqlite-Database.

    It works very well if the combobox is not editable. If I set the combobox editable and open the dialog, the right data is shown in the combobox, but if I submit the column is empty. If I choose any data in the popup-list of the combobox and submit the data the right data is in the database.

    So:
    If I only open the dialog and close it (including "submit") the data of the combobox is deleted in the database. If I open the dialog and edit the combobox, the right data is in the database.

    Has anybody an idea why I loose the data of the editable combobox?

    Thank you!

    Franz

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on 24 Jun 2015, 02:19 last edited by
      #2

      I am not sure,
      but I guess editable combobox does not update model until editingFinished signal is emmited for
      QLineEdit * QComboBox::lineEdit ()

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mr. Kibu
        wrote on 24 Jun 2015, 18:16 last edited by
        #3

        Ok, but if I use the editable combobox without a relation (e.g. a stringlist), than everything works too.

        Is it possible that there is a additional thing I have to regard using relations?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alex_malyu
          wrote on 24 Jun 2015, 22:07 last edited by
          #4

          @Mr.-Kibu said:

          QDataWidgetMapper

          I do not have experience with QDataWidgetMapper,
          and not sure I understand the logic correctly but it seems you may try to map QLineEdit provided by combobox instead of combobox itself. According to what I read in documentation this may be a solution.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mr. Kibu
            wrote on 25 Jun 2015, 12:14 last edited by
            #5

            I can map like this:

            mMapVoucherPos->addMapping(ui->cbCostCenter->lineEdit,8);

            and the combobox in the dialog shows the right value, but I cannot submit to the model!

            1 Reply Last reply
            0

            2/5

            24 Jun 2015, 02:19

            • Login

            • Login or register to search.
            2 out of 5
            • First post
              2/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved