diff --git a/src/rviz/properties/splitter_handle.cpp b/src/rviz/properties/splitter_handle.cpp index 3c2ec46a50..c385f6222c 100644 --- a/src/rviz/properties/splitter_handle.cpp +++ b/src/rviz/properties/splitter_handle.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -42,12 +43,14 @@ SplitterHandle::SplitterHandle(QTreeView* parent) { setCursor(Qt::SplitHCursor); updateGeometry(); + parent_->header()->setStretchLastSection(false); parent_->installEventFilter(this); } bool SplitterHandle::eventFilter(QObject* event_target, QEvent* event) { - if (event_target == parent_ && (event->type() == QEvent::Resize || event->type() == QEvent::Paint)) + if (event_target == parent_ && + (event->type() == QEvent::Resize || event->type() == QEvent::LayoutRequest)) { updateGeometry(); } @@ -57,13 +60,10 @@ bool SplitterHandle::eventFilter(QObject* event_target, QEvent* event) void SplitterHandle::updateGeometry() { int w = 7; - int content_width = parent_->contentsRect().width(); - int new_column_width = int(first_column_size_ratio_ * content_width); - if (new_column_width != parent_->columnWidth(0)) - { - parent_->setColumnWidth(0, new_column_width); - parent_->setColumnWidth(1, content_width - new_column_width); - } + int new_column_width = int(first_column_size_ratio_ * parent_->contentsRect().width()); + parent_->setColumnWidth(0, new_column_width); + parent_->setColumnWidth(1, parent_->viewport()->contentsRect().width() - new_column_width); + int new_x = new_column_width - w / 2 + parent_->columnViewportPosition(0); if (new_x != x() || parent_->height() != height()) setGeometry(new_x, 0, w, parent_->height());