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

QDataWidgetMapper cause wrong focus handling on Qt::ActiveWindowFocusReason

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.14.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Windows, VS2019, 32bit
    • Platform/s:
      Windows

      Description

      I probably found a bug in QDataWidgetMapper but I want to make sure this is not intentional or some side-effect.

      I have two QLineEdits, one is attached to QDataWidgetMapper and the second not.

       

      auto model = new QStringListModel(QStringList({"1","2"}));
      auto pWidgetMapper = new QDataWidgetMapper(this);
      pWidgetMapper->setModel(model);
      pWidgetMapper->setCurrentIndex(0);
      pWidgetMapper->addMapping(ui->lineEditMapped, 0);
      

        

      Now, when I have a focus on QLineEdit without widget mapper and I do ALT+TAB to switch to another app and then back to my tab, the focus is correctly restored to this QLineEdit.

      But, when the focus is on QLineEdit WITH widget mapper, the focus isn't restored at all.

      My configuration: Qt 5.14, VS2019, Win10

       

      Edit:

       

      It seems that it's sufficient to add these two lines to broke focus handling:

       

       

      auto pWidgetMapper = new QDataWidgetMapper(this);
      auto pWidgetMapper = new QDataWidgetMapper(this); pWidgetMapper->addMapping(ui->lineEditMapped, 0);
      

       

        Attachments

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

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            ludek.vodicka Ludek Vodicka
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes