sherox
sherox

Reputation: 370

Change vertical header title

How I can change title shown on the picture to "№". Thanks.

enter image description here

Upvotes: 4

Views: 1096

Answers (1)

eyllanesc
eyllanesc

Reputation: 243907

That widget is an object of the QTableCornerButton class that inherits from QAbstractButton but it is a class that is part of the private Qt API that does not use text, so you can not use setText() of QAbstractButton, so the other option is establish a QLabel with a layout above:

#include <QtWidgets>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QTableView w;
    QStandardItemModel model(10, 10);
    w.setModel(&model);
    QAbstractButton *button =  w.findChild<QAbstractButton *>();
    if(button){
        QVBoxLayout *lay = new QVBoxLayout(button);
        lay->setContentsMargins(0, 0, 0, 0);
        QLabel *label = new QLabel("№");
        label->setContentsMargins(0, 0, 0, 0);
        lay->addWidget(label);
    }
    w.show();
    return a.exec();
}

enter image description here

Upvotes: 4

Related Questions