QHeaderView* headerView = new QHeaderView(Qt::Horizontal, this); headerView->setDefaultAlignment(Qt::AlignHCenter);
QTableView* tableView = new QTableView(this); tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignRight);In this example, a new table view is created and the default alignment for the horizontal header is set to align right. The QHeaderView class is part of the QtWidgets library.