How to add custom header to QTableWidget
How can I add a custom header to my QTableWidget?
I have derived a class MyHeaderItem from QWidget and QTableWidgetItem and set an instance of it into the table. I have copied the code below.
This does not work. Column 0 in the table shows an empty header. What am I missing?
I need a custom header because I want to place several strings and icons in the header.
Is there some other technique to add a custom header to QTableWidget?
Code:
{
public:
{
mWidget.setupUi( this );
}
private:
Ui_simple_widget mWidget;
};
MyHeaderItem* headerItem = new MyHeaderItem( myTable );
myTable->setHorizontalHeaderItem( 0, headerItem );
Re: How to add custom header to QTableWidget
If your MyHeaderItem is derived from QWidget, then you need the Q_OBJECT macro in the class definition. Besides that, I have no idea if it is even possible to use a QWidget as a header item. You don't show that you have implemented the clone() method, and I would think that would be an important one.
Re: How to add custom header to QTableWidget
See below link, in which example is given for Hierarchical headers for QTableView, see if it can help you to get some idea for QTableWidget.
http://qt-apps.org/content/show.php/...content=103154