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

QDataWidgetMapper doesn't set interger Property value if database field value is NULL

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.5.1
    • None
    • All

    Description

      Steps to reproduce the issue:
      1. To have a widget that is capable to display an integer value;
      2. To link this widget with an integer field in database table via QDataWidgetMapper;
      3. Select table row where given field has NULL value.
      Result:
      Nothing will happen.
      Expected result:
      QDataWidgetMapper should update widget with 0 value (It isn't possible to convert NULL into valid integer so 0 should be set by analogy as empty string '' is set for text widgets).

      I attach an example which does following:
      1. It has 2 widgets - one is of QString type and another of int type.
      String widget will display "TEST" as initial value and integer widget will display 999 as initial value.
      2. In-memory database is created with 1 table of 2 fields: field1 is string, field2 is int.
      3. Widgets are connected with corresponding fields with help of QDataWidgetMapper.
      4. On button push data are selected from the database and QDataWidgetMapper is pointed to the first row of the table.
      As result you will see that first widget will display nothing because it was updated with empty string by QDataWidgetMapper, but 2nd widget will keep value 999 because it was not updated (It is visible from debug output also - you may see that only line NEW STR VALUE: "" is printed in console - i.e. method CustomIntEdit.setValue() isn't called in this case at all).

      You may uncomment line #65 to make a test when both fields have valid values.
      In this case you will see that both widgets are updated by QDataWidgetMapper and 2 lines are printed in console debug output:
      NEW STR VALUE: "aaa"
      NEW INT VALUE: 111

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            starterkit Ivan Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes