QHeaderView *header = new QHeaderView(Qt::Horizontal, tableView); header->setSectionsClickable(true); int visualIndex = header->visualIndex(3);
QHeaderView *verticalHeader = new QHeaderView(Qt::Vertical, tableView); int index = verticalHeader->logicalIndexAt(visualIndex);In this example, we create a new vertical QHeaderView to be used with a QTableView. We use a previously obtained visual index to get the logical index of the section as it appears in the model. The Qt library package is required for using QHeaderView in C++ programming.