Hello. The text was written by a translator, so I apologize if something is incorrect.
I need to render values in real time and resize the box to fit more items when the window is stretched and fewer when the window shrinks.
The function of adding points is standard
auto yMax = _yAxis->range().upper; auto xMax = _xAxis->range().upper; auto xMin = _xAxis->range().lower; QVector<double> keys; QVector<double> values; keys.reserve(data.size() - 17); values.reserve(data.size() - 17); auto step = 0.0; for(int i = 17; i < data.size(); i++){ keys.append(xMax + step); values.append(indexTo(data[i])); } _xAxis->moveRange(step); _audioGraph->addData(keys, values);
The range when stretching and shrinking the main window changes in the event function
void Window::resizeEvent(QResizeEvent* event){ if (!event->oldSize().isValid()) return; int step = event->size().width() - event->oldSize().width(); auto oldG = ui->chartWidget->geometry(); oldG.setWidth(oldG.width() + step); ui->chartWidget->setGeometry(oldG); _xAxis->setRange(_xAxis->range().lower - step, _xAxis->range().upper); }
But due to the compression of the axis, the graph is also compressed. What is the right thing to do in this case?