Disable horz. scrollbar for legends

This commit is contained in:
jonjenssen 2023-03-14 15:12:36 +01:00 committed by jonjenssen
parent 09c04cbcd0
commit a926421825

View File

@ -26,6 +26,7 @@
#include <QDebug> #include <QDebug>
#include <QResizeEvent> #include <QResizeEvent>
#include <QScrollArea>
#include <QVariant> #include <QVariant>
#include <utility> #include <utility>
@ -35,7 +36,6 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuQwtPlotLegend::RiuQwtPlotLegend( QWidget* parent /*= nullptr */ ) RiuQwtPlotLegend::RiuQwtPlotLegend( QWidget* parent /*= nullptr */ )
: QwtLegend( parent ) : QwtLegend( parent )
{ {
auto* legendLayout = qobject_cast<QwtDynGridLayout*>( contentsWidget()->layout() ); auto* legendLayout = qobject_cast<QwtDynGridLayout*>( contentsWidget()->layout() );
if ( legendLayout ) if ( legendLayout )
@ -44,6 +44,9 @@ RiuQwtPlotLegend::RiuQwtPlotLegend( QWidget* parent /*= nullptr */ )
legendLayout->setSpacing( 1 ); legendLayout->setSpacing( 1 );
} }
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding ); setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding );
QScrollArea* scrollArea = findChild<QScrollArea*>( "QwtLegendView" );
if ( scrollArea ) scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------