set table column resize mode to strech

This commit is contained in:
laserpants 2016-03-20 12:17:59 +03:00
parent 6dde549c82
commit fc933ae16c
2 changed files with 11 additions and 3 deletions

View File

@ -1,3 +1,6 @@
#include <QDebug>
#include <QEvent>
#include <QHeaderView>
#include "table.h" #include "table.h"
Table::Table(QWidget *parent) Table::Table(QWidget *parent)
@ -13,7 +16,12 @@ Table::~Table()
{ {
} }
bool Table::eventFilter(QObject *obj, QEvent *event) void Table::paintEvent(QPaintEvent *event)
{ {
return QTableWidget::eventFilter(obj, event); QHeaderView *header = horizontalHeader();
for (int i = 0; i < header->count(); ++i) {
header->setSectionResizeMode(i, QHeaderView::Stretch);
}
QTableWidget::paintEvent(event);
} }

View File

@ -12,7 +12,7 @@ public:
~Table(); ~Table();
protected: protected:
bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
}; };
#endif // TABLE_H #endif // TABLE_H