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

QDataWidgetMapper cause wrong focus handling on Qt::ActiveWindowFocusReason

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.14.0
    • None
    • Windows, VS2019, 32bit
    • 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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            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