Important: Please read the Qt Code of Conduct -

Enumeration of the rows(Vertical Header) is not aligned horizontally with data in the table

  • Hi All,

    I am facing this issue with QTableWidget where the vertical header having enumeration for the rows in the table is not aligned horizontally with the data in the rows.


    Is there any setting that can help me to get these in correct alignement

  • Lifetime Qt Champion


    How are you setting up that QTableView ?
    By the way, which version of Qt is it ?
    On what OS ?

  • Hi

    QT version: 5.11 and its on Windows.
    What do you mean by setting up QTable View? What information is needed for this??
    Made a member of QTable view and added a QAbstractTableModel as its model.

    Setting up the row count and column count for the table using the model. Using header data to set the column headers and row numbers:
    QVariant DINModel::headerData(int section, Qt::Orientation orientation, int role) const {
    if (role != Qt::DisplayRole)
    return QVariant();

    if (orientation == Qt::Horizontal) {
    	switch (section)
    	case portType:
    		return "Port";
    	case labelType:
    		return "Event Label";
    	case dinType:
    		return "Digital Input";
    else {
    	return QString("%1").arg(section + 1);
    return QVariant();


  • Lifetime Qt Champion

    Then please provide the complete code of your model so it can be tested.

Log in to reply