QHeaderView: - avoid cursor move on setDefaultSectionSize

If we are reacting on the sectionResized signal and we call
setDefaultSectionSize we should ensure that we are not moving
the mouse-cursor.

This is an improvement of f8f6acb05c

Change-Id: I1adee7821bc8fcc9633f692bfd515f2c458b12c8
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
Thorbjørn Lund Martsum 2012-11-22 19:49:05 +01:00 committed by The Qt Project
parent dfc0fbabe1
commit 8d4544f00d
2 changed files with 3 additions and 2 deletions

View File

@ -3375,6 +3375,8 @@ void QHeaderViewPrivate::setDefaultSectionSize(int size)
executePostedLayout();
invalidateCachedSizeHint();
defaultSectionSize = size;
if (state == QHeaderViewPrivate::ResizeSection)
preventCursorChangeInSetOffset = true;
for (int i = 0; i < sectionItems.count(); ++i) {
QHeaderViewPrivate::SectionItem &section = sectionItems[i];
if (sectionHidden.isEmpty() || !sectionHidden.testBit(i)) { // resize on not hidden.

View File

@ -65,8 +65,7 @@ void SomeHandler::slotSectionResized(int logsection, int oldsize, int newsize)
m_tv->setUpdatesEnabled(false);
// Do some manual resizing - lets make every section having the new size.
m_hv->blockSignals(true);
for (int u = 0; u < m_hv->count(); ++u)
m_hv->resizeSection(u, newsize);
m_hv->setDefaultSectionSize(newsize);
m_hv->blockSignals(false);
// Adjust offset and scrollbar. Maybe it isn't 100% perfect