QAbstractTableModel에서 상속받은 동일한 클래스 (TableModel)에서 상속 한 2 개의 tableView가 있습니다. 내가 2 테이블에 대한 헤더를 추가하고 싶습니다하지만 이러한 헤더는 각 테이블에 대해 서로 다른해야합니다. 내 테이블 모델에서 나는이 방법을 가지고있다 :같은 tableModel 클래스에서 상속 한 두 테이블의 다른 헤더
QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) return QVariant(); if (orientation == Qt::Horizontal) { switch (section) { case 0: return tr("Header1"); case 1: return tr("Header2"); case 2: return tr("Header3"); default: return QVariant(); } } return QVariant(); }
그러나 이것은 테이블 중 하나에서만 작동 할 것이다. 어떻게 다른 테이블에 다른 헤더를 설정할 수 있습니까?
당신은 테이블 모델에서 상속 테이블 뷰를 가지고 있습니까? –
예 ... 두 테이블 뷰가 동일한 모델에 대한 포인터를 공유하는 경우 테이블 모델 – schmimona