C++ (Qt)#include <QApplication>#include <QTableView>#include <QHeaderView>#include <QStringListModel>//class HeaderView: public QHeaderView {public: HeaderView(Qt::Orientation orientation, QWidget * parent = 0) : QHeaderView(orientation, parent) {}};//int main(int argc, char *argv[]) { QApplication app(argc, argv); QStringListModel model(QStringList() << "foo"); QTableView v1; v1.setWindowTitle("Standard header"); v1.setModel(&model); v1.show(); QTableView v2; v2.setWindowTitle("Custom header"); v2.setModel(&model); v2.setHorizontalHeader(new HeaderView(Qt::Horizontal, &v2)); v2.show(); return app.exec();}
C++ (Qt)class HeaderView: public QHeaderView { Q_OBJECTpublic: HeaderView(Qt::Orientation orientation, QWidget * parent = 0) : QHeaderView(orientation, parent) {}};