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

QTest::mouseClick behaves different to an actual hardware mouse click (multiple combo boxes open; ignoring window modality)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2.2
    • Testing: qtestlib
    • None
    • - Manjaro Linux, Kernel 5.10
      - i3 Window Manager running X11
      - Qt 6.2.2
    • Linux/X11

    Description

      I discovered two scenarios where the QTest::mouseClick function behaves differently to a click with a real hardware mouse. I added sample code for both scenarios.

      First Scenario: The main window has two widgets of type QComboBox, called leftComboBox and rightComboBox

      When clicking the first QComboBox (leftComboBox) with QTest::mouseClick, leftComboBox will open as expected. A subsequent call to QTest::mouseClick on the other combo box, rightComboBox, will open rightComboBox and leave leftComboBox open (attached is a screenshot of this behavior). With a real hardware mouse the result would be that leftComboBox would be closed and rightComboBox would not be opened.
      A similar bug to this is when both combo boxes are closed. Then QTest::mouseClick is used to open leftComboBox. A subsequent call to QTest::mouseClick somewhere in the main window where no widget is, will result in leftComboBox staying open, and QMainWindow registers the click (debugged by checking the mousePressEvent() function of QMainWindow, it will print a debug message if the main window registers a click). With a real hardware mouse the expected result would be that the second click somewhere in main window closes leftComboBox and the main window does not register a click.

      Second Scenario: The main window has a QComboBox widget called comboBox and a modal QDialog is currently shown

      A QTest::mouseClick call on the combo box of the main window (called comboBox) will open comboBox. The expected result with a hardware mouse would be that nothing happens, because the open QDialog is modal and currently shown.
      A similar bug to this is, when the modal dialog is shown, but the QTest::mouseClick is executed on the main window, where no widget is present. Again as in the first scenario, the main window registers that click (again, a debug message will be printed if the main window registers a click). With a hardware mouse the expected result would be that no click is registered as the dialog is modal and shown.

      The sample code for both scenarios is attached. In the constructor of the MainWindow are single shot timers to trigger the scenarios. For both scenarios I added two additional timers which show the "similar bugs" as I mentioned earlier. To see the similar bugs, uncomment the timers and comment out the other ones (should be clear which ones).

      Attachments

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

        Activity

          People

            macadder Jason McDonald
            pdeubel Patrick Deubel
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes