Displaying tabular data using Table Widget
In this recipe, we will learn to display data in tabular format, that is, in the row and column format. We will display the different room types of a hotel and their respective rents per day.
Getting ready
Before we begin creating this recipe, let's first understand Table Widget
.
Table Widget
Table Widget
is used for displaying data in tabular format, arranged in rows and columns. Table Widget
is an instance of the QTableWidget
class and the items that are displayed in the different rows and columns of a table are instances of the QTableWidgetItem
class. Here are the methods provided by the QTableWidget
class:
setRowCount()
: This method is used to define the number of rows you want inTable Widget
setColumnCount()
: This method is used to define the number of columns required inTable Widget
rowCount()
: This method returns the number of rows in the tablecolumnCount()
: This method returns the number of columns in the tableclear()
: This method clears the...