diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index a2f565505d..b1b665fc3b 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -262,6 +262,8 @@ PacketList::PacketList(QWidget *parent) : setUniformRowHeights(true); setAccessibleName("Packet list"); + header()->setStretchLastSection(false); + overlay_sb_ = new OverlayScrollBar(Qt::Vertical, this); setVerticalScrollBar(overlay_sb_); @@ -430,6 +432,17 @@ PacketListModel *PacketList::packetListModel() const { void PacketList::showEvent (QShowEvent *) { setColumnVisibility(); + + int column_width = 0; + for (int col = 0; col < packet_list_model_->columnCount(); col++) { + column_width += columnWidth(col); + } + + if (column_width < viewport()->width()) { + header()->setStretchLastSection(true); + applyRecentColumnWidths(); + header()->setStretchLastSection(false); + } } void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) { @@ -703,11 +716,16 @@ void PacketList::fieldsChanged(capture_file *cf) // Called via recentFilesRead. void PacketList::applyRecentColumnWidths() { +// bool saved_stretch = header()->stretchLastSection(); +// header()->setStretchLastSection(false); + // Either we've just started up or a profile has changed. Read // the recent settings, apply them, and save the header state. for (int col = 0; col < prefs.num_cols; col++) { setRecentColumnWidth(col); } + +// header()->setStretchLastSection(saved_stretch); column_state_ = header()->saveState(); }