void RawDataWindow::layoutPlots()
{
QWidget *ui_plotAreaWidget
= qFindChild<QWidget
*>
( this,
"plotAreaWidget" );
// Remove all plots from the layout to adjust spacing and setup reparenting
for( int p = 0; p < mPlots.count(); p++ )
{
plotLayout->removeWidget( mPlots.at( p ).plotObject );
// Note this line was "causing" the first plot to ALWAYS draw behind the others
// Removing this "fixes" the layout AFTER adding a third plot object
//mPlots.at( p ).plotObject->setParent( 0 );
}
if( mPlots.count() == 1 )
{
plotLayout->addWidget( mPlots.at( 0 ).plotObject, 0, 0, 1, 1 );
}
else if( mPlots.count() == 2 )
{
// Create a 1x2 grid
plotLayout->addWidget( mPlots.at( 0 ).plotObject, 0, 0, 1, 1 );
plotLayout->addWidget( mPlots.at( 1 ).plotObject, 0, 1, 1, 1 );
}
else if( mPlots.count() == 3 )
{
// 2x2 grid with the top plot spanning across both columns
plotLayout->addWidget( mPlots.at( 0 ).plotObject, 0, 0, 1, 2 );
plotLayout->addWidget( mPlots.at( 1 ).plotObject, 1, 0, 1, 1 );
plotLayout->addWidget( mPlots.at( 2 ).plotObject, 1, 1, 1, 1 );
}
else if( mPlots.count() == 4 )
{
// 2x2 grid
plotLayout->addWidget( mPlots.at( 0 ).plotObject, 0, 0, 1, 1 );
plotLayout->addWidget( mPlots.at( 1 ).plotObject, 0, 1, 1, 1 );
plotLayout->addWidget( mPlots.at( 2 ).plotObject, 1, 0, 1, 1 );
plotLayout->addWidget( mPlots.at( 3 ).plotObject, 1, 1, 1, 1 );
}
}
void RawDataWindow::layoutPlots()
{
QWidget *ui_plotAreaWidget = qFindChild<QWidget*>( this, "plotAreaWidget" );
QGridLayout *plotLayout = (QGridLayout*) ui_plotAreaWidget->layout();
// Remove all plots from the layout to adjust spacing and setup reparenting
for( int p = 0; p < mPlots.count(); p++ )
{
plotLayout->removeWidget( mPlots.at( p ).plotObject );
// Note this line was "causing" the first plot to ALWAYS draw behind the others
// Removing this "fixes" the layout AFTER adding a third plot object
//mPlots.at( p ).plotObject->setParent( 0 );
}
if( mPlots.count() == 1 )
{
plotLayout->addWidget( mPlots.at( 0 ).plotObject, 0, 0, 1, 1 );
}
else if( mPlots.count() == 2 )
{
// Create a 1x2 grid
plotLayout->addWidget( mPlots.at( 0 ).plotObject, 0, 0, 1, 1 );
plotLayout->addWidget( mPlots.at( 1 ).plotObject, 0, 1, 1, 1 );
}
else if( mPlots.count() == 3 )
{
// 2x2 grid with the top plot spanning across both columns
plotLayout->addWidget( mPlots.at( 0 ).plotObject, 0, 0, 1, 2 );
plotLayout->addWidget( mPlots.at( 1 ).plotObject, 1, 0, 1, 1 );
plotLayout->addWidget( mPlots.at( 2 ).plotObject, 1, 1, 1, 1 );
}
else if( mPlots.count() == 4 )
{
// 2x2 grid
plotLayout->addWidget( mPlots.at( 0 ).plotObject, 0, 0, 1, 1 );
plotLayout->addWidget( mPlots.at( 1 ).plotObject, 0, 1, 1, 1 );
plotLayout->addWidget( mPlots.at( 2 ).plotObject, 1, 0, 1, 1 );
plotLayout->addWidget( mPlots.at( 3 ).plotObject, 1, 1, 1, 1 );
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks