Skip to content

Commit

Permalink
Fix repositioning of filter widgets after the second click on the header
Browse files Browse the repository at this point in the history
This happened only for the custom dark/light styles.

The new connects fixes the issue for me. This was discovered by trial and
error, because I don't know what is really causing the problem (seems
some bug relating with event ordering and maybe a race condition).

Second change is irrelevant for the issue, just for optimization of the
loop.

See comment:
#2558 (comment)
  • Loading branch information
mgrojo committed Sep 6, 2023
1 parent eaf92cf commit 9c2c858
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/FilterTableHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ FilterTableHeader::FilterTableHeader(QTableView* parent) :

// Do some connects: Basically just resize and reposition the input widgets whenever anything changes
connect(this, &FilterTableHeader::sectionResized, this, &FilterTableHeader::adjustPositions);
connect(this, &FilterTableHeader::sectionClicked, this, &FilterTableHeader::adjustPositions);
connect(parent->horizontalScrollBar(), &QScrollBar::valueChanged, this, &FilterTableHeader::adjustPositions);
connect(parent->verticalScrollBar(), &QScrollBar::valueChanged, this, &FilterTableHeader::adjustPositions);

Expand Down Expand Up @@ -75,13 +76,13 @@ void FilterTableHeader::updateGeometries()

void FilterTableHeader::adjustPositions()
{
// The two adds some extra space between the header label and the input widget
const int y = QHeaderView::sizeHint().height() + 2;
// Loop through all widgets
for(int i=0;i < static_cast<int>(filterWidgets.size()); ++i)
{
// Get the current widget, move it and resize it
QWidget* w = filterWidgets.at(static_cast<size_t>(i));
// The two adds some extra space between the header label and the input widget
int y = QHeaderView::sizeHint().height() + 2;
if (QApplication::layoutDirection() == Qt::RightToLeft)
w->move(width() - (sectionPosition(i) + sectionSize(i) - offset()), y);
else
Expand Down

0 comments on commit 9c2c858

Please sign in to comment.