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?
{
public:
{
mWidget.setupUi( this );
}
private:
Ui_simple_widget mWidget;
};
MyHeaderItem* headerItem = new MyHeaderItem( myTable );
myTable->setHorizontalHeaderItem( 0, headerItem );
class MyHeaderItem : public QWidget, public QTableWidgetItem
{
public:
MyHeaderItem( QWidget* parent ) : QWidget( parent ), QTableWidgetItem( 0 )
{
mWidget.setupUi( this );
}
private:
Ui_simple_widget mWidget;
};
MyHeaderItem* headerItem = new MyHeaderItem( myTable );
myTable->setHorizontalHeaderItem( 0, headerItem );
To copy to clipboard, switch view to plain text mode
Bookmarks