My custom Qt Designer widget does not change size!
Solved
General and Desktop
-
Hi,
I have a custom chart defined like this:
QtCustomChart::QtCustomChart(QWidget *parent) : QWidget(parent) { series = new QLineSeries; series->append(0, 6); series->append(2, 4); series->append(3, 8); series->append(7, 4); series->append(10, 5); chart = new QChart(); chart->legend()->hide(); chart->addSeries(series); chart->createDefaultAxes(); chart->setTitle("Simple Line Chart"); chart_view = new QChartView{ chart, this}; auto rec = chart_view->geometry(); auto r = this->geometry(); chart_view->setGeometry(r); }
The icon is visible in Qt Designer so the plugin is ok. However when I resize the chart in the target ui, it does not resize the chart!!
How do I make the plugin to grow and shrink?
Regards,
Juan -
@jdent I implemented resizeEvent like this:
QtCustomChart::QtCustomChart(QWidget *parent) : QWidget(parent) { series = new QLineSeries; series->append(0, 6); series->append(2, 4); series->append(3, 8); series->append(7, 4); series->append(10, 5); chart = new QChart(); chart->legend()->hide(); chart->addSeries(series); chart->createDefaultAxes(); chart->setTitle("Simple Line Chart"); chart_view = new QChartView{ chart, this}; auto rec = chart_view->geometry(); rect = this->geometry(); chart_view->setGeometry(rect); } // the event: void QtCustomChart::resizeEvent(QResizeEvent* event) { auto r = this->geometry(); if (r.height() < rect.height() || r.width() < rect.height()) { chart_view->setGeometry(rect); } QWidget::resizeEvent(event); }
but it is not changing the size of the chart!!
-
-
@jdent said in My custom Qt Designer widget does not change size!:
How do I make the plugin to grow and shrink?
You apply a layout to the widget rather than resorting to manually dealing with the geometry of the client chart