You could customize every single header column by using setHorizontalHeaderItem or just set the text in all column header by using setHorizontalHeadersLabels .
An easy way to implement your attached image is by customizing your own QWidget. Use a vertical layour and consider your Icp (mA) header as a custom label with a center alignment.
Then insert your QTableWidget and set the headers as (3kOmega, 5.1kOmega & 11kOmega). Something like this:
QWidget* container = new QWidget(this);
QVBoxLayout* layout = new QVBoxLayout(this);
// Custom label
QLabel* header = new QLabel(this);
header->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
header->setAlignment(Qt::AlignHCenter);
header->setText("Icp (mA)");
// Custom QTableWidget
QTableWidget* table = new QTableWidget(this);
table->setColumnCount(3);
QStringList LIST;
LIST << "3k" << "11k" << "15k";
table->setHorizontalHeaderLabels(LIST);
table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
table->horizontalHeader()->setStretchLastSection(true);
layout->addWidget(header);
layout->addWidget(table);
container->setLayout(layout);
setCentralWidget(container);
Giving you something like this:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.