mirror of
https://github.com/leozide/leocad
synced 2025-01-18 22:26:44 +01:00
Preserve interactive stretch when navigating across tabs
This commit is contained in:
parent
aedfa16e42
commit
e71ed90b3d
2 changed files with 14 additions and 5 deletions
|
@ -47,7 +47,7 @@ float lcParseValueLocalized(const QString& Value)
|
|||
|
||||
// Resize all columns to content except for one stretching column. (taken from QT creator)
|
||||
lcQTreeWidgetColumnStretcher::lcQTreeWidgetColumnStretcher(QTreeWidget *treeWidget, int columnToStretch)
|
||||
: QObject(treeWidget->header()), m_columnToStretch(columnToStretch), m_stretchWidth(0)
|
||||
: QObject(treeWidget->header()), m_columnToStretch(columnToStretch), m_interactiveResize(false), m_stretchWidth(0)
|
||||
{
|
||||
parent()->installEventFilter(this);
|
||||
connect(treeWidget->header(), SIGNAL(sectionResized(int, int, int)), SLOT(sectionResized(int, int, int)));
|
||||
|
@ -60,7 +60,14 @@ void lcQTreeWidgetColumnStretcher::sectionResized(int LogicalIndex, int OldSize,
|
|||
Q_UNUSED(OldSize)
|
||||
|
||||
if (LogicalIndex == m_columnToStretch)
|
||||
{
|
||||
QHeaderView* HeaderView = qobject_cast<QHeaderView*>(parent());
|
||||
|
||||
if (HeaderView->isVisible())
|
||||
m_interactiveResize = true;
|
||||
|
||||
m_stretchWidth = NewSize;
|
||||
}
|
||||
}
|
||||
|
||||
bool lcQTreeWidgetColumnStretcher::eventFilter(QObject* Object, QEvent* Event)
|
||||
|
@ -79,6 +86,7 @@ bool lcQTreeWidgetColumnStretcher::eventFilter(QObject* Object, QEvent* Event)
|
|||
}
|
||||
else if (Event->type() == QEvent::Hide)
|
||||
{
|
||||
if (!m_interactiveResize)
|
||||
for (int i = 0; i < HeaderView->count(); ++i)
|
||||
HeaderView->setSectionResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ private slots:
|
|||
|
||||
private:
|
||||
const int m_columnToStretch;
|
||||
bool m_interactiveResize;
|
||||
int m_stretchWidth;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue