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

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

XMLWordPrintable

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

      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)
      

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes