Is it possible to set the text of the QTableView corner button?

前端 未结 2 457
野的像风
野的像风 2021-01-06 08:00

QTableView has a corner button, occupying the intersection between the horizontal and the vertical header. Clicking this will select all cells in the table. What I\'m wonder

2条回答
  •  粉色の甜心
    2021-01-06 08:36

    You can add text on the corner button by finding a child from QTableWidget and add a QLabel to it by using the vertical layout as below.

    QAbstractButton* button = qFindChild< QAbstractButton* >(TableWidget);
    if (button) 
    {
        QVBoxLayout* lay = new QVBoxLayout(button);
        lay->setContentsMargins(0, 0, 0, 0);
        QLabel* label = new QLabel("No");
        label->setStyleSheet("QLabel {font-face: ArialMT; font-size: 10px; color: #FFFFFF; font-weight: bold; }""QToolTip { color: #ffffff; background-color: #000000; border: 1px #000000; }");
        label->setAlignment(Qt::AlignCenter);
        label->setToolTip("Text");
        label->setContentsMargins(2, 2, 2, 2);
        lay->addWidget(label);
    }
    

提交回复
热议问题