from PyQt5.QtWidgets import QTableWidget, QTableWidgetItem, QApplication # create the table widget table = QTableWidget() # create a new table item with text and set the font item = QTableWidgetItem('Hello World') item.setFont(QFont('Arial', 16)) # add the item to the table widget table.setItem(0, 0, item) # show the table widget table.show() # start the application event loop app = QApplication([]) app.exec_()
from PyQt5.QtWidgets import QTableWidget, QTableWidgetItem, QApplication # create the table widget table = QTableWidget() # create a list of data with different fonts data = [('John', 'Verdana', 12), ('Jane', 'Times New Roman', 14), ('Bob', 'Calibri', 10)] # loop through the data and add a new table item with the correct font for each row for row, (name, font_name, font_size) in enumerate(data): item = QTableWidgetItem(name) item.setFont(QFont(font_name, font_size)) table.setItem(row, 0, item) # show the table widget table.show() # start the application event loop app = QApplication([]) app.exec_()In this example, we create a table widget and a list of data with different font properties for each row. We loop through the data and create a new QTableWidgetItem for each row with the correct font properties, then we add the item to the table. Finally, we show the table widget and start the application event loop.