Results 1 to 3 of 3

Thread: QwtPlot, problem with large plotwidth

  1. #1
    Join Date
    Jan 2015
    Location
    Germany, Munich
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default QwtPlot, problem with large plotwidth

    Dear all,

    I have to plot a curve with - lets say - 40000 (or more) points. The solution I found is to do this in a QScrollArea. For the first 32800 (round about) points this works very good and I can scroll (x-axis) my curve without problems. But for points greater than 32800 the area is just black. Please see the code below to reproduce the behaviour. (I am using Opensuse 13.1 64bit, qwt-6.1.2, qt-4.8.5). Thanks in advance for your help.

    ---------------------
    #include <qwt_plot_curve.h>
    #include <qwt_plot.h>
    #include <qwt_plot_canvas.h>
    #include <qwt_plot_layout.h>
    #include <qwt_scale_engine.h>
    #include <qapplication.h>
    #include <qscrollarea.h>
    #include <QAbstractScrollArea>
    #include <QVBoxLayout>
    #include <QLabel>
    #include <qmainwindow.h>
    #include <math.h>

    #define PLOTWIDTH 40000

    int main(int argc, char **argv)
    {
    QApplication my_qt_app(argc, argv);
    double x[PLOTWIDTH];
    double y[PLOTWIDTH];
    int i;

    for (i=0;i<PLOTWIDTH;i++) {
    x[i] = (double) i;
    y[i] = sin(((double)i * M_PI)/180.);
    }

    QWidget mainw;
    QVBoxLayout *mainLayout = new QVBoxLayout(&mainw);

    QScrollArea *sau = new QScrollArea();
    sau->setMinimumSize(1000, 420);

    QwtPlot *plotu = new QwtPlot();
    plotu->setFixedSize(PLOTWIDTH, 400);
    plotu->setAxisScale(QwtPlot::xBottom,0,PLOTWIDTH,100);
    plotu->setPalette( Qt::gray );
    plotu->setCanvasBackground( Qt::white);

    QwtPlotCurve *my_curve = new QwtPlotCurve();
    my_curve->setRawSamples(x, y, PLOTWIDTH);
    my_curve->setPen(* new QPen(QColor(0xff,0x10,0))); /* red */
    my_curve->attach(plotu);
    sau->setWidget(plotu);
    mainLayout->addWidget(sau);

    mainw.show();
    return my_qt_app.exec();
    }
    --------------------------------------------------

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,253
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot, problem with large plotwidth

    I would strongly discourage your QScrollArea approach - you will run into many, many problems with this huge widget - better use the approach you find in the realtime example ( zoom in and you will see scrollbars ).
    Concerning the 32800 I would guess that you find a limitation somewhere because of unsigned shorts.

    Uwe

  3. #3
    Join Date
    Jan 2015
    Location
    Germany, Munich
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QwtPlot, problem with large plotwidth

    Thanks Uwe,

    BR
    Walter

Similar Threads

  1. Replies: 12
    Last Post: 22nd August 2012, 15:45
  2. [Problem] Qt load large image
    By rstalin in forum Qt Programming
    Replies: 2
    Last Post: 11th October 2011, 19:21
  3. QGLWidget: problem with very large images
    By gitarooLegend in forum Qt Programming
    Replies: 6
    Last Post: 8th September 2011, 15:58
  4. Sending large datagrams(very large)
    By marcel in forum General Programming
    Replies: 1
    Last Post: 16th February 2008, 22:55
  5. QTable resize problem with large tables
    By Robzzz in forum Newbie
    Replies: 3
    Last Post: 22nd May 2006, 15:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.