PDA

View Full Version : Customizig QTableWidget



backtotech
22nd February 2016, 09:14
Hello Everyone,
I am trying customize the QTableWidget. I need to do the following :

1. Change headings or the QHeaderview with background color, font size.
2. and for the column, the Column size, font size , back ground color

I try to subclass the headerview, but not much of luck. If someone can guide me on this, or point me to a sample, that would be of great help. Also tried CSS , it worked in some cases , but not much luck so far

d_stranz
22nd February 2016, 17:46
If you are using QTableWidget and not QTableView, then you retrieve the QTableWidgetItem for your widget's header using QTableWidget::horizontalHeaderItem(). You can customize the item to your heart's content.

QTableWidget is derived from QTableView. In that base class you can find the methods to customize the column width.

If you want the entire table to have the same font, you can set that using QWidget::setFont(). If you want individual cells to have their own font and background colors, then you do that as you add the individual QTableWidgetItem instances to the table.