Custom TableWidget QHeaderView
Unsolved
General and Desktop
-
class QCustomTableView : public QTableWidget { Q_OBJECT private: QHeaderView* m_pHeaderview; public: QCustomTableView(QObject* parent); QCustomTableView(Qt::Orientation orientation, QObject *parent); } QCustomTableView::QCustomTableView(Qt::Orientation orientation, QObject *parent) { m_pHeaderview = new QHeaderView(orientation, this); this->setHorizontalHeader(m_pHeaderview); this->setEditTriggers(QAbstractItemView::EditTrigger::NoEditTriggers); this->horizontalHeader()->setStretchLastSection(true); QString strStyle("\ QHeaderView::section\ {\ background-color: #00599C;\ padding: 4px;\ border: 40px;\ border-color: red;\ font-family: Microsoft YaHei UI;\ font-size: 10pt;\ color: #FFFFFF;\ }\ QTableWidget\ {\ gridline-color: #003863;\ font-size: 10pt;\ border: 4px;\ border-color: #002039;\ }\ QTableWidget QTableCornerButton::section\ {\ background-color: #00599C;\ border: 4px solid #003863;\ }\ "); this->setStyleSheet(strStyle); }
I made a customized table widget, but the horizontal header is not accessible and null, so I made a new one and put it in the set horizontal header.
But the style sheet didn't work. I used to check the style sheet.Is there a way?