• 5561阅读
  • 6回复

[提问]QwtPlot画图显示不正常 [复制链接]

上一主题 下一主题
离线安德森
 
只看楼主 倒序阅读 楼主  发表于: 2013-12-23
关键词: qwt绘图
今天写了一个绘图程序,但运行时有些不正常。我设置了开始按钮作为触发,当我触发按钮时画布不显示图形,但我放大自己做的窗口时,又有了图形,附上绘图程序。
void MainWindow::insertCurve(const QString &title,const QVector<QPointF>& samples, const QColor &color)//设置曲线
{
    d_curve = new QwtPlotCurve( title );
    d_curve->setRenderHint( QwtPlotItem::RenderAntialiased );//反锯齿
    d_curve->setStyle( QwtPlotCurve::Lines );
    d_curve->setPen(QPen(Qt::blue));
    d_curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol );

    QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse );//用“0”做标志
    symbol->setSize( 4 );
    symbol->setPen( color );
    d_curve->setSymbol( symbol );

    d_curve->setSamples( samples );
    d_curve->attach( ui->qwtPlot );
    ui->qwtPlot->show();
}
plot的初始化应该正常,不知道哪里的问题
(二楼附图)
离线安德森
只看该作者 1楼 发表于: 2013-12-23

第一张没有显示图形(其实已经绘制好了)
第二张我点最大化后出现的图形。
求高手指点
离线friendbaby

只看该作者 2楼 发表于: 2013-12-23
在函数最后添加 ui->qwtPlot->replot();
Smiling is best language , can express everything , also can conceal everything.
离线安德森
只看该作者 3楼 发表于: 2013-12-24
回 2楼(friendbaby) 的帖子
正常了,可是为什么先前的不行。一般是有数据改动才学要replot(),这是第一次画,为什么也要加replot()?
离线friendbaby

只看该作者 4楼 发表于: 2013-12-24
The autoReplot option is set to false by default, which means that the user has to call replot() in order to make changes visible.
Smiling is best language , can express everything , also can conceal everything.
离线friendbaby

只看该作者 5楼 发表于: 2013-12-24
回 3楼(安德森) 的帖子
    d_curve->setSamples( samples );
    d_curve->attach( ui->qwtPlot );

这不算是数据改动吗?
Smiling is best language , can express everything , also can conceal everything.
离线安德森
只看该作者 6楼 发表于: 2013-12-24
是的,以前用QPainter()时是这样的,换了个就犯糊涂了。
快速回复
限100 字节
 
上一个 下一个