Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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.

    0_1563515809048_07053fb3-115c-47eb-a611-8210872e7af2-image.png

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


  • Lifetime Qt Champion

    Hi,

    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";
    		break;
    	case labelType:
    		return "Event Label";
    		break;
    	case dinType:
    		return "Digital Input";
    		break;
    	}
    }
    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