#include <QFontMetrics>
#include <QFont>
void TableWidget::setH(QStringList strlist)
{
setHorizontalHeaderLabels(strlist);
int sizeAll = 0;
QList<int > sizeList;
for (int i = 0; i < strlist.size();i++)
{
QFontMetrics fontMetrics(font());
int nFontWidth = fontMetrics.width(strlist.at(i));
sizeAll = sizeAll+nFontWidth;
sizeList.append(nFontWidth);
}
for (int i = 0; i < sizeList.size();i++)
{
setColumnWidth(0, sizeList.at(i) / sizeAll);
}
}