Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2407

QTest.keySequence with Shift modifier breaks QTableWidget.selectRow/selectColumn

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 6.5.2, 6.4.0.1, 6.5.1.1
    • PySide
    • None
    • Linux/Other display system, Windows

    Description

      After QTest.keySequence(window, "Shift+A"), QTableWidget.selectRow (and selectColumn) are ineffective. This example code shows the problem: it should print "Pass" four times, but prints "Pass/Fail/Fail/Pass" instead. I am using Python 3.11.4.
       
       

      from PySide6.QtTest import QTest
      from PySide6.QtWidgets import QApplication, QMainWindow, QTableWidget, QTableWidgetItem
      
      def fun(run):
          print(f"Run {run}")
      
          table = QTableWidget(1, 1)
          item = QTableWidgetItem()
          table.setItem(0, 0, item)
          table.clearSelection()
      
          if run == 0:
              # This works fine
              table.selectRow(0)
          if run == 1:
              # *After QTest.keySequence*, selectRow does not seem to do anything:
              table.selectRow(0)
          elif run == 2:
              # Same with selectColumn
              table.selectColumn(0)
          elif run == 3:
              # By contrast, selectAll does work:
              table.selectAll()
      
          if table.selectedItems() == [item]:
              print("Pass")
          else:
              print("Fail")
          print()
      
      if __name__ == "__main__":
          application = QApplication()
          window = QMainWindow()
      
          fun(0)
          QTest.keySequence(window, "Shift+A")
      
          fun(1)
          fun(2)
          fun(3)
      

      Attachments

        Issue Links

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

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              bers bers bers
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes