Graphic legend minimum size fix
This commit is contained in:
@@ -30,6 +30,7 @@ __GraphicRegistrator__ __graphic_registrator__;
|
|||||||
class LegendScrollArea: public QScrollArea {
|
class LegendScrollArea: public QScrollArea {
|
||||||
public:
|
public:
|
||||||
LegendScrollArea(QWidget * w): QScrollArea() {
|
LegendScrollArea(QWidget * w): QScrollArea() {
|
||||||
|
minimum_hei = 0;
|
||||||
setFrameShape(QFrame::NoFrame);
|
setFrameShape(QFrame::NoFrame);
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
setWidgetResizable(true);
|
setWidgetResizable(true);
|
||||||
@@ -40,6 +41,7 @@ public:
|
|||||||
viewport()->setAutoFillBackground(false);
|
viewport()->setAutoFillBackground(false);
|
||||||
w->setAutoFillBackground(false);
|
w->setAutoFillBackground(false);
|
||||||
}
|
}
|
||||||
|
int minimum_hei;
|
||||||
protected:
|
protected:
|
||||||
virtual QSize sizeHint() const {
|
virtual QSize sizeHint() const {
|
||||||
QSize ret;
|
QSize ret;
|
||||||
@@ -47,6 +49,9 @@ protected:
|
|||||||
ret = widget()->sizeHint();
|
ret = widget()->sizeHint();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
virtual QSize minimumSizeHint() const {
|
||||||
|
return QSize(1, minimum_hei);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1597,15 +1602,29 @@ void Graphic::updateLegend(bool es) {
|
|||||||
int row = 0, col = 0;
|
int row = 0, col = 0;
|
||||||
bool lv = ui->scrollLegend->isVisibleTo(this);
|
bool lv = ui->scrollLegend->isVisibleTo(this);
|
||||||
ui->scrollLegend->hide();
|
ui->scrollLegend->hide();
|
||||||
|
LegendScrollArea * leg_sa = (LegendScrollArea *)ui->scrollLegend->layout()->itemAt(0)->widget();
|
||||||
for (int i = 0; i < graphics.size(); i++) {
|
for (int i = 0; i < graphics.size(); i++) {
|
||||||
ui->layoutLegend->addWidget(graphics[i].pb,row,col);
|
ui->layoutLegend->addWidget(graphics[i].pb,row,col);
|
||||||
graphics[i].pb->show();
|
QCheckBox * check = graphics[i].pb;
|
||||||
|
check->show();
|
||||||
|
if (leg_sa->minimum_hei == 0) {
|
||||||
|
leg_sa->minimum_hei = ui->widgetLegend->sizeHint().height();
|
||||||
|
/*#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||||
|
QTimer::singleShot(0, this, [this,leg_sa,check](){
|
||||||
|
leg_sa->minimum_hei = check->sizeHint().height();
|
||||||
|
leg_sa->updateGeometry();
|
||||||
|
qDebug() << leg_sa->minimum_hei << ui->widgetLegend->sizeHint();
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
leg_sa->minimum_hei = check->sizeHint().height();
|
||||||
|
#endif*/
|
||||||
|
}
|
||||||
col++;
|
col++;
|
||||||
if (col > maxcol) {col = 0; row++;}
|
if (col > maxcol) {col = 0; row++;}
|
||||||
}
|
}
|
||||||
ui->gridLayout->invalidate();
|
ui->gridLayout->invalidate();
|
||||||
ui->scrollLegend->setVisible(lv);
|
ui->scrollLegend->setVisible(lv);
|
||||||
ui->scrollLegend->layout()->itemAt(0)->widget()->updateGeometry();
|
leg_sa->updateGeometry();
|
||||||
//ui->gridLayout->invalidate();
|
//ui->gridLayout->invalidate();
|
||||||
leg_update = true;
|
leg_update = true;
|
||||||
if (es) emit graphicSettingsChanged();
|
if (es) emit graphicSettingsChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user