2 Attachment(s)
Re: updating Widget doesn't work
Hello
I created two windows: "PlotWindow" and "TableWindow"
Attachment 10615
When I click on the button "Show Plot" I expect to see a new graph:
Code:
{
int rowCount = model.rowCount();
QVector<double> x( rowCount ), y( rowCount ); // initialize with entries 0..100
for ( int row = 0; row < rowCount; ++row ) {
record = model.record( row );
x[row] = record.fieldName( 0 ).toDouble();
y[row] = record.fieldName( 1 ).toDouble();
}
// create graph and assign data to it:
ui->plotWidget->addGraph();
ui->plotWidget->graph( 0 )->setData( x, y );
// give the axes some labels:
ui->plotWidget->xAxis->setLabel( "x" );
ui->plotWidget->yAxis->setLabel( "y" );
// set axes ranges, so we see all data:
ui->plotWidget->xAxis->setRange( -1, 1 );
ui->plotWidget->yAxis->setRange( 0, 1 );
ui->plotWidget->update();
}
How you can see below I wrote: ui->plotWidget->update();
But when I resize my PlotWindow I see the right result:
Attachment 10616
Added after 7 minutes:
This is my source code: https://github.com/8Observer8/PlotAndTable
Re: updating Widget doesn't work
You should use:
Code:
ui->plotWidget->replot();
to update the plot immediately.
update() will not call the QCustomPlot's paint event until you resize/click etc.
HTH.
Re: updating Widget doesn't work
Thank you very much! It is excellent! :D