{
Q_OBJECT
public:
CustomHeader
(int columnCount
= 0,
QWidget *parent
= 0) {
l->setContentsMargins(0,0,0,0);
l->setSpacing(0);
l->addWidget(table);
table->setFixedHeight(55);
for(int i=0; i<columnCount; i++)
{
DelayedLineEdit* lineEdit = new DelayedLineEdit(this);
lineEdit->setDelay(700);
lineEdit->setIndex(i);
table->setCellWidget(0, i, lineEdit);
connect(lineEdit,
SIGNAL(delayTextChanged
(QString)),
this,
SLOT(applyColumnFilter
(QString)));
}
table->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
table->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
table->verticalHeader()->hide();
setLayout(l);
setFixedHeight(50);
}
private:
};
{
Q_OBJECT
public:
{
// Horizontal header treatement:
header()->hide();
m_header = new CustomHeader(m_treeModel->columnCount(), this);
}
~treeView();
protected:
setViewportMargins(0,60, 0, 0);
m_header->setGeometry(0, 0, viewport()->width(), m_header->sizeHint().height());
}
setViewportMargins(0, m_header->sizeHint().height(), 0, 0);
m_header->setGeometry(0, 0, viewport()->width(), m_header->sizeHint().height());
}
private:
CustomHeader *m_header;
};
class CustomHeader : public QHeaderView
{
Q_OBJECT
public:
CustomHeader(int columnCount = 0, QWidget *parent = 0)
{
QHBoxLayout *l = new QHBoxLayout(this);
l->setContentsMargins(0,0,0,0);
l->setSpacing(0);
table = new QTableWidget(1, columnCount, this);
l->addWidget(table);
table->setFixedHeight(55);
for(int i=0; i<columnCount; i++)
{
DelayedLineEdit* lineEdit = new DelayedLineEdit(this);
lineEdit->setDelay(700);
lineEdit->setIndex(i);
table->setCellWidget(0, i, lineEdit);
connect(lineEdit, SIGNAL(delayTextChanged(QString)), this, SLOT(applyColumnFilter(QString)));
}
table->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
table->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
table->verticalHeader()->hide();
setLayout(l);
setFixedHeight(50);
}
private:
QTableWidget* table;
};
class treeView : public QTreeView
{
Q_OBJECT
public:
treeView(QWidget *parent = 0)
{
// Horizontal header treatement:
header()->hide();
m_header = new CustomHeader(m_treeModel->columnCount(), this);
}
~treeView();
protected:
void resizeEvent(QResizeEvent *event) {
setViewportMargins(0,60, 0, 0);
m_header->setGeometry(0, 0, viewport()->width(), m_header->sizeHint().height());
}
void showEvent(QShowEvent *) {
setViewportMargins(0, m_header->sizeHint().height(), 0, 0);
m_header->setGeometry(0, 0, viewport()->width(), m_header->sizeHint().height());
}
private:
CustomHeader *m_header;
};
To copy to clipboard, switch view to plain text mode
Bookmarks