QHeaderView section headers
I created QTableWidget
, hung my QHeaderView
on it, and it turned out like this:
Code:
TableViewer = new QTableWidget(1, 2, this);
QHeaderView * hHeader = new QHeaderView(Qt::Horizontal);
TableViewer->setHorizontalHeader(hHeader);
QHeaderView * vHeader = new QHeaderView(Qt::Vertical);
TableViewer->setVerticalHeader(vHeader);
TableViewer->show();
Next, I read the doc on QHeaderView
and QAbstractItemView
and did not find anywhere how to change the section headers (columns/rows), in my case, it is necessary to replace 1 and 2 in the columns with their own labels, how to do this?
Well, or even hide the header, so that only the cells are displayed in the widget window.
2
Author: Дух сообщества, 2015-04-08
2 answers
To change the title text, call the setHeaderData
method on the model.
To hide:
view->horizontalHeader()->hide();
view->verticalHeader()->hide();
4
Author: zenden2k, 2015-04-08 06:04:22
QListString Ls << "One" << "Two" << "Three";
TableViewer->setHorizontalHeaderLabels(Ls);
0
Author: Day, 2015-04-19 12:05:48