Skip to content

Commit

Permalink
fix legend truncation for panels
Browse files Browse the repository at this point in the history
  • Loading branch information
ElderOrb committed Jul 3, 2024
1 parent 0d177d7 commit 26fd856
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Source/GUI/PlotLegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//---------------------------------------------------------------------------

#include "GUI/PlotLegend.h"
#include <qwt_graphic.h>
#include <qwt_legend_label.h>
#include <qwt_dyngrid_layout.h>
#include <QScrollArea>
#include <QLayout>

Expand All @@ -23,9 +25,10 @@ PlotLegend::PlotLegend( QWidget *parent ):
setMaxColumns( 1 );
setContentsMargins( 0, 0, 0, 0 );

QLayout* layout = contentsWidget()->layout();
QwtDynGridLayout* layout = qobject_cast<QwtDynGridLayout*> (contentsWidget()->layout());
layout->setAlignment( Qt::AlignLeft | Qt::AlignTop );
layout->setSpacing( 0 );
layout->setSpacing(0);
layout->setExpandingDirections(Qt::Horizontal);

QScrollArea *scrollArea = findChild<QScrollArea *>();
if ( scrollArea )
Expand All @@ -51,12 +54,15 @@ PlotLegend::~PlotLegend()
QWidget *PlotLegend::createWidget( const QwtLegendData &data ) const
{
QWidget *w = QwtLegend::createWidget( data );
w->setMaximumHeight(10);
auto icon = data.icon();
if(!icon.isNull())
w->setMaximumHeight(10);

QwtLegendLabel *label = dynamic_cast<QwtLegendLabel *>( w );
if ( label )
{
label->setMargin( 0 );
label->setContentsMargins(0, 0, 0, 0);
}

return w;
Expand Down

0 comments on commit 26fd856

Please sign in to comment.