Fit QTableWidget headers
-
Hi! I am using item-based QTableWidget. So I created some headers... Now I want to fit headers in %-age for QTableWidget width.
@
QStringList h;
h << "Lorem" << "Ipsum" << "Dolor" << "Sit";
QStringList v;
for(int k = 'A'; k <= 'N'; k++) {
v << QString(QChar(k));
}
ui->schedule->setHorizontalHeaderLabels(h);
ui->schedule->setVerticalHeaderLabels(v);
@This code leaves clear space in the right side of table. How to fit it?
-
I found a way using [ (width / 100) * %-age ] where sum of %-ages == 100;
But I want to find Qt-Way.
-
There is no simple Qt method to share the space niceley between columns. You might want to consider setting stretchLastSection of the [[Doc:QHeaderView]] to true. This will allocate the remaining space to the last column.