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

QTableWidgetItem setForeground not working

XMLWordPrintable

    • Windows

      trying to change the textcolor of a QTableWidgetItem with setForeground(QColor(x,x,x)) doesn't seem to work.

      if i run this simple script:

      from PySide6.QtWidgets import QApplication, QTableWidget, QTableWidgetItem
      from PySide6.QtGui import QColor
      app = QApplication([])
      
      # Create a QTableWidget with 1 row and 1 column
      table_widget = QTableWidget(1, 1)
      
      # Create a QTableWidgetItem
      item = QTableWidgetItem("Hello, World!")
      
      # Change the text color to red
      item.setForeground(QColor(255, 0, 0))
      
      # Add the item to the table
      table_widget.setItem(0, 0, item)
      
      # Show the table widget
      table_widget.show()
      
      # Run the application
      app.exec_() 

      i get the following window:

      The "Hello, World!" text should be red.

       

      It worked with version 6.6.3.1

      It also works on Linux (Kubuntu 22.04.3 LTS)

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            cmellueh Christoph Mellüh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes