Qwt plot not working , simple plot curve not appeat

Posted by user1629213 on Stack Overflow See other posts from Stack Overflow or by user1629213
Published on 2014-06-13T03:21:34Z Indexed on 2014/06/13 3:24 UTC
Read the original article Hit count: 397

Filed under:
|
|

I followed the example of simple plot in qwt examples to plot a curve. The axis and the graph appear in the Qt main window user interface but the curve not. I assigned values to fit the curve but the curve not appear. Any suggestions and help how to solve the problem? Here is my code

MainWindow::MainWindow( int argc, char** argv, QWidget *parent )
 : QMainWindow( parent )
 , qnode( argc,argv )
{
    ui.setupUi( this ); // Calling this incidentally connects all ui's triggers to on_...() callbacks in this class.
        QObject::connect( ui.actionAbout_Qt, SIGNAL( triggered( bool )), qApp, SLOT( aboutQt( ))); // qApp is a global variable for the application
        ReadSettings( );
     setWindowIcon( QIcon( ":/images/icon.png" ));
     ui.tab_manager->setCurrentIndex( 0 ); // ensure the first tab is showing - qt-designer should have this already hardwired, but often loses it (settings?).
         QObject::connect( &qnode, SIGNAL( rosShutdown( )), this, SLOT( close( )));

    /*********************
    ** Logging
    **********************/
    ui.view_logging->setModel( qnode.loggingModel( ));
        QObject::connect( &qnode, SIGNAL( loggingUpdated( )), this, SLOT( updateLoggingView( )));
        QObject::connect( &qnode, SIGNAL( graphReceived( )), this, SLOT( onGraphReceived( )));
        QObject::connect( &qnode, SIGNAL( parameterReceived( )), this, SLOT( onParameterReceived( )));
    /*********************
    ** Auto Start
    **********************/
    if ( ui.checkbox_remember_settings->isChecked( ))
    {
        on_button_connect_clicked( true );
    }
    ui.parameters->setAttribute( Qt::WA_NoMousePropagation );
    ui.parameters->setAttribute( Qt::WA_OpaquePaintEvent );
    ui.plotgraph->setAttribute( Qt::WA_NoMousePropagation );
    ui.plotgraph->setAttribute( Qt::WA_OpaquePaintEvent );

            p_plot = new QwtPlot(ui.plotgraph);
            p_plot->setTitle( "Plot LinVel" );
            p_plot->setCanvasBackground( Qt::white );
            // Axis
            p_plot->setAxisTitle( QwtPlot::xBottom, "Time(sec)" );
            p_plot->setAxisTitle( QwtPlot::yLeft, "Linear Velocity (m/sec)" );
            p_plot->setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );
            p_plot->setAxisScale( QwtPlot::xBottom, 0.0, 50.0 );
            p_plot->insertLegend( new QwtLegend() );

            //samplingThread.start();
            QwtPlotGrid *grid = new QwtPlotGrid();
            grid->attach( p_plot );

            curve = new QwtPlotCurve();
            curve->setTitle( "Linear velocity" );
            // Set curve styles
            curve->setPen( Qt::blue, 4 ),
            curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );

            QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
            QBrush( Qt::yellow), QPen( Qt::red, 2 ), QSize( 8, 8 ) );
            curve->setSymbol( symbol);

            // Assign values to the curve
            //curve->setSamples(ui.plotgraph.get_linv_g());//yaw_g,trav_g,wall_g;
            curve->attach( p_plot );

            p_plot->resize( 600, 400 );
            p_plot->show();

void MainWindow::onGraphReceived( )
{
 {
        QMutexLocker locker( &qnode.m_mutex );
    }
}


void MainWindow::onParameterReceived( )
{
    {
        QMutexLocker locker( &qnode.m_mutex );
        std::vector<double> p_ = qnode.get_parameters();
        std::cout << p_[0]<<" "<<p_[1]<<" "<<p_[2]<<" "<<p_[3]<<" "<<p_[4] << std::endl;
    }
}

Any help?

© Stack Overflow or respective owner

Related posts about qt

Related posts about plot