Trying to get simple first template example for plotting using the brand new QwtPlotOpenGLCanvas class which is based on QOpenGLWidget

I was trying to get necessary parts from the refreshtest example.

Here is what I have first separately in my widget.cpp as a declaration:
Qt Code:
  1. class GLCanvas: public QwtPlotOpenGLCanvas
  2. {
  3. public:
  4. GLCanvas( QwtPlot *parent = NULL ):
  5. QwtPlotOpenGLCanvas( parent )
  6. {
  7. setContentsMargins( 1, 1, 1, 1 );
  8. }
  9.  
  10. protected:
  11. virtual void paintEvent( QPaintEvent *event )
  12. {
  13. QPainter painter( this );
  14. painter.setClipRegion( event->region() );
  15.  
  16. QwtPlot *plot = qobject_cast< QwtPlot *>( parent() );
  17. if ( plot )
  18. plot->drawCanvas( &painter );
  19.  
  20. painter.setPen( palette().foreground().color() );
  21. painter.drawRect( rect().adjusted( 1, 1, 0, 0 ) );
  22. }
  23. };
To copy to clipboard, switch view to plain text mode 

then inside of the Widget constructor I have this code:
Qt Code:
  1. QwtPlotOpenGLCanvas *plotCanvas = qobject_cast<QwtPlotOpenGLCanvas *>( canvas() );
  2. if ( plotCanvas == NULL )
  3. {
  4. plotCanvas = new GLCanvas();
  5. plotCanvas->setPalette( QColor( "yellow" ) );
  6.  
  7. setCanvas( plotCanvas );
  8.  
  9. }
To copy to clipboard, switch view to plain text mode 

Here are my concerns/questions:

1) When I tried the above experiment with old QwtPlotGLCanvas, I did have a proper widget with yellow colored canvas. So I assume it was working. But after I changed it to be QwtPlotOpenGLCanvas based, mo matter what palette I set with
Qt Code:
  1. plotCanvas->setPalette( QColor( "yellow" ) );
To copy to clipboard, switch view to plain text mode 
the color is always black, why? Is it a bug, or am I supposed to set something more when changing to QwtPlotOpenGLCanvas ?

2) How to plot data now? For example, before, without OpenGL, we would do something like this
Qt Code:
  1. QwtPlot *plot = new QwtPlot(this);
To copy to clipboard, switch view to plain text mode 
and then create a curve and do
Qt Code:
  1. curve->attach( plot );
To copy to clipboard, switch view to plain text mode 
However; right now I cannot attach curve like that because it will complain that argument to the attach function is not of QwtPlot * type, so How am I supposed to do it properly?