Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QT QCUSTOM plot flickering problem



  • i am using qcustomplot (line) to display incoming data.

    ***How can I update the qcustomplot without flickering the display (smooth data update)***? Because so far I have managed to display incoming data but the display is flickering every time it updates the value.

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    int xx=0;
    int a[2048]={47,45,45,46,47,45,46,46,47,45,46,45,45,45,48,43,45,45,45,47,44,47,47,45,45,44,45,46,45,46,46,45,45,44,47,47,46,45,45,46,45,45,46,46,46,45,45,45,46,47,47,47,45,46,46,46,45,44,46,45,45,46,44,46,45,45,46,47,47,45,46,46,45,45,45,47,46,47,45,45,45,45,45,45,47,45,47,45,46,46,47,45,44,46,44,45,46,46,46,46,
                 45,47,47,44,46,48,45,47,46,46,47,44,45,46,45,46,46,46,46,46,46,46,46,46,45,46,45,45,44,45,46,45,45,45,44,45,45,46,45,46,45,46,47,44,46,46,45,45,45,46,46,46,47,47,44,45,47,45,44,45,44,45,46,46,47,47,46,45,46,44,46,46,46,45,45,46,46,44,46,47,46,46,45,45,46,46,47,47,47,46,47,47,46,44,46,47,46,46,47,46,
                 46,46,46,46,4,47,4,45,47,46,48,47,47,47,46,46,46,46,45,46,45,45,46,46,46,47,47,47,46,45,46,46,46,45,47,46,46,45,45,45,45,47,46,49,46,46,46,45,48,47,47,46,46,47,48,45,46,45,46,48,47,46,48,44,45,46,46,45,46,46,47,44,47,47,47,47,46,48,46,46,46,47,47,46,45,45,45,45,48,47,47,45,47,46,46,48,46,46,49,46,46,
                 46,46,47,47,46,48,47,47,46,47,47,45,46,44,46,46,46,46,46,46,46,46,47,45,45,46,45,45,46,46,48,46,47,44,46,46,45,45,44,47,45,47,47,45,46,46,47,46,46,47,47,46,47,45,47,46,48,47,46,47,47,47,45,48,45,45,47,47,46,45,45,46,46,46,46,47,46,47,46,48,46,46,46,47,46,45,47,48,47,46,47,46,47,47,45,47,46,46,47,45,
                 46,45,46,47,46,46,46,44,46,47,46,47,48,46,47,46,46,46,46,46,47,46,46,45,47,45,47,46,46,47,47,46,47,46,46,46,46,46,46,47,47,46,47,47,46,46,47,46,46,47,46,48,46,47,46,46,46,45,46,46,45,47,47,47,48,46,45,47,46,45,46,49,46,45,48,47,45,48,46,46,46,47,45,45,47,47,46,44,46,46,46,47,45,46,47,45,46,46,46,48,
                 46,46,45,47,46,47,47,47,47,47,46,46,46,46,46,46,47,45,46,46,45,46,45,45,47,44,45,46,46,45,44,46,46,45,45,44,46,47,46,48,45,47,45,46,48,46,47,45,46,46,47,45,46,47,46,44,49,47,45,47,46,46,45,45,45,46,46,47,47,45,45,45,47,45,45,46,46,48,48,46,47,46,47,46,47,45,46,46,48,45,47,45,46,46,45,46,46,46,45,46,
                 46,49,46,48,47,47,46,45,48,46,48,46,47,46,47,47,46,47,46,46,45,46,47,45,46,46,46,46,46,45,46,47,45,45,46,45,45,47,46,46,46,45,47,46,47,47,47,47,47,47,45,47,47,47,47,45,47,45,45,47,46,44,45,44,46,47,45,47,45,46,46,47,46,45,45,45,45,46,47,46,47,45,45,46,45,46,46,46,45,47,46,45,47,45,46,45,46,45,46,44,
                 45,45,47,46,46,47,46,46,47,46,46,45,47,44,46,46,45,45,45,45,44,47,46,47,45,45,46,44,45,47,46,44,45,45,45,46,46,47,46,45,46,46,47,47,47,46,45,46,47,46,46,46,45,46,47,47,46,46,44,47,46,46,46,47,46,46,46,46,46,46,46,45,46,45,48,46,46,46,45,44,46,46,45,46,47,46,46,45,46,47,45,46,46,47,46,47,46,48,46,45,
                 47,46,45,47,47,46,47,47,46,45,46,45,47,47,46,46,45,46,47,47,46,45,45,46,47,46,46,47,47,45,45,45,46,45,44,46,47,45,47,47,45,45,45,45,45,46,47,46,46,44,47,45,47,45,45,45,44,47,47,46,45,45,46,46,48,46,44,46,47,45,45,45,46,44,46,46,44,47,46,45,45,46,47,46,46,46,45,47,45,47,46,46,45,46,46,46,47,45,46,46,
                 47,45,46,46,46,46,46,47,46,45,46,46,45,47,48,47,45,46,46,47,46,45,46,47,47,45,46,47,46,46,46,45,46,46,46,46,46,46,45,46,45,46,46,47,46,46,46,46,45,45,43,47,45,47,45,46,45,45,45,46,45,45,46,45,47,45,46,47,46,44,45,47,45,46,45,45,45,45,45,44,45,46,47,47,46,45,45,45,43,44,45,45,44,45,45,46,45,45,46,45,
                 45,46,43,45,45,44,45,45,45,44,44,44,45,44,46,46,46,46,45,46,45,46,45,46,46,46,45,45,45,47,44,46,45,45,45,45,45,46,45,45,44,45,45,45,45,45,46,45,45,45,45,46,45,46,44,45,47,45,45,45,45,45,46,48,45,47,45,47,46,46,47,47,48,48,46,46,46,46,45,46,49,46,45,46,47,47,47,45,46,46,47,44,46,46,46,46,47,47,46,46,
                 47,46,46,46,46,46,46,46,46,45,47,45,45,46,48,46,46,45,47,45,45,47,46,44,46,45,45,48,45,46,44,47,45,46,46,45,46,45,46,45,46,45,46,47,46,45,46,47,47,46,46,45,46,45,45,44,46,46,45,47,45,47,46,46,45,45,46,45,47,47,45,46,46,46,46,44,44,46,44,44,46,45,46,46,46,46,45,43,45,46,45,48,45,45,47,47,47,44,46,46,
                 46,46,46,45,47,47,46,45,48,46,45,47,46,45,46,46,45,46,44,47,46,46,47,45,45,45,46,44,46,46,46,45,46,44,46,44,48,47,46,46,48,47,45,46,47,46,45,46,45,47,45,46,45,46,46,47,47,46,45,47,45,48,47,45,46,46,45,45,46,46,46,47,46,48,47,45,45,44,47,46,45,46,47,46,46,47,48,45,45,46,46,44,45,45,46,48,48,46,46,48,
                 46,46,47,45,47,47,46,45,45,47,46,46,45,45,46,47,47,46,47,48,46,45,46,45,46,44,46,47,46,46,48,45,45,47,46,46,47,47,46,46,46,45,46,45,47,45,45,46,46,46,46,48,45,46,46,47,47,47,46,46,46,48,46,47,45,47,46,45,45,47,46,47,47,47,46,47,46,46,46,48,46,46,45,46,46,46,46,46,45,48,46,46,46,46,46,45,47,43,48,44,
                 44,45,47,46,47,46,46,47,45,46,45,46,45,46,46,47,47,48,45,45,45,46,46,45,47,46,46,46,43,45,47,44,46,47,47,46,46,45,47,46,46,46,46,46,48,45,45,46,47,46,46,46,45,46,46,47,45,45,46,45,45,46,45,46,46,48,45,46,47,46,45,46,45,46,46,45,45,46,44,46,44,46,46,46,48,47,46,46,45,46,46,45,46,47,45,47,46,47,45,45,
                 47,45,45,44,45,47,46,46,47,44,46,47,47,46,46,46,45,46,46,47,46,46,46,48,45,46,46,47,47,47,43,46,47,46,47,44,46,48,46,44,44,47,46,46,45,47,47,48,46,46,46,46,46,47,44,48,47,46,45,46,47,46,46,46,45,46,47,46,46,46,47,47,45,46,44,46,46,46,46,46,46,46,45,46,45,48,45,46,47,45,45,47,46,47,47,45,46,46,46,46,
                 47,46,46,45,47,46,46,47,46,46,46,48,47,46,46,46,47,45,46,47,48,46,46,45,46,47,46,46,46,45,45,46,45,45,47,47,47,46,47,46,46,47,46,47,46,44,46,47,45,46,45,47,47,45,45,46,47,47,45,46,47,45,46,45,45,45,45,46,46,46,44,47,45,46,46,46,46,46,46,46,45,46,46,47,46,47,46,46,46,45,46,45,44,46,43,48,47,44,46,45,
                 46,45,46,47,46,46,45,45,45,46,46,45,46,46,46,45,46,46,46,45,47,45,45,45,45,46,46,46,45,45,46,44,47,44,46,46,46,45,47,45,45,45,45,45,45,46,44,44,45,45,46,45,46,44,47,46,45,46,45,44,45,47,44,46,46,46,45,47,45,45,44,46,46,46,44,45,44,45,46,45,45,47,46,44,46,45,45,45,46,46,45,44,46,45,46,45,46,48,44,45,
                 45,46,46,44,45,45,45,46,46,47,46,47,45,46,47,44,44,45,45,46,46,46,46,44,45,45,44,45,47,45,45,45,47,47,44,44,46,44,45,44,44,45,46,45,46,45,47,45,45,46,45,46,45,46,46,45,45,46,46,45,45,44,45,45,45,45,45,46,45,46,44,45,44,45,44,46,46,43,46,46,45,45,45,45,46,46,47,47,45,45,46,44,44,45,45,46,45,44,45,45,
                 43,46,46,44,47,45,45,45,44,45,45,45,46,46,45,43,44,46,44,46,46,44,45,44,45,46,45,46,46,46,45,45,46,46,47,44,43,46,43,44,45,45,45,46,44,46,44,44,43,46,45,45,45,46,46,45,44,46,45,45,45,45,46,45,43,45,44,43,46,45,45,45,45,45,45,44,44,46,45,45,43,43,44,45,44,45,45,45,45,44,42,45,44,45,43,43,44,45,44,45,
                 45,44,45,43,45,44,46,45,44,44,47,45,45,47,43,44,44,45,44,45,46,44,45,45,47,45,45,42,44,45,44,46,45,44,45,44,43,41,45,45,44,44,43,44,43,42,43};
    int c[2048]={150,149,143,148,151,151,150,150,149,149,152,148,148,147,146,152,149,150,147,151,150,149,148,149,152,150,148,150,147,149,149,149,149,151,152,151,149,148,151,147,151,147,150,147,151,150,154,150,151,151,151,151,154,154,150,152,148,151,150,148,150,151,149,151,150,156,155,159,158,154,154,151,152,154,155,
                 150,154,149,150,149,154,152,155,150,154,152,155,150,149,154,150,156,154,150,151,150,151,155,151,157,151,152,150,151,148,150,150,157,150,156,150,147,155,150,155,155,152,150,154,151,152,151,150,152,151,157,151,152,150,149,154,152,154,154,151,151,150,150,157,154,154,155,150,155,157,150,152,151,156,151,
                 150,152,152,154,155,150,155,150,150,156,154,149,152,154,154,154,151,150,156,148,150,157,150,154,150,154,154,154,156,150,150,155,156,155,156,154,154,150,154,155,158,151,154,154,150,150,156,151,148,150,151,150,154,150,156,150,154,151,154,150,150,157,154,155,154,157,155,156,152,155,155,157,154,159,156,
                 156,154,155,154,156,156,151,152,150,150,156,154,152,159,150,150,158,150,155,156,155,156,155,155,154,154,154,155,155,155,154,149,156,150,156,150,155,155,156,157,150,157,157,151,157,157,158,152,150,156,155,154,154,155,156,154,154,156,150,157,154,150,157,157,152,155,155,154,154,155,154,156,156,150,155,154,157,155,156,156,150,155,157,154,157,154,161,155,155,155,158,156,156,150,154,155,155,157,157,157,152,155,156,159,155,154,154,155,157,151,159,154,157,154,157,158,154,155,155,155,159,155,156,156,157,154,158,155,160,157,157,158,158,155,158,155,155,155,150,159,156,157,158,156,157,156,154,156,158,157,156,159,156,157,158,155,157,154,157,155,157,156,157,157,159,156,157,156,162,158,155,159,156,156,159,155,157,155,158,155,162,156,157,154,163,157,158,156,161,157,156,157,156,154,158,159,160,156,159,159,157,159,155,162,159,156,155,157,154,155,156,157,156,157,155,159,157,160,150,157,158,152,157,155,154,158,155,158,158,158,155,158,156,156,157,159,156,159,156,157,157,156,156,158,155,155,160,150,158,154,159,157,154,157,155,157,159,154,157,150,155,155,155,152,155,159,158,155,155,158,156,154,154,155,157,157,154,158,155,159,155,160,156,159,157,155,150,160,156,150,154,157,150,158,155,150,154,157,155,158,160,158,154,159,157,157,157,155,156,159,154,157,160,154,155,157,156,150,156,157,156,158,150,156,156,154,157,156,159,158,158,156,155,156,155,156,155,160,155,156,158,157,154,150,158,157,155,157,155,158,156,159,156,157,159,157,156,157,159,154,160,158,158,160,156,155,154,161,159,160,157,156,154,155,154,156,159,158,155,154,150,158,162,156,156,155,154,160,159,162,160,159,158,161,150,159,156,155,160,158,159,158,155,161,155,157,154,154,156,150,156,163,154,149,160,160,155,159,155,156,155,150,157,158,157,157,154,157,155,158,155,156,156,156,155,150,156,157,155,155,155,157,157,157,157,155,157,157,155,159,158,150,156,157,155,158,156,158,155,154,157,157,156,155,156,155,160,157,159,150,158,155,162,157,159,159,155,156,154,155,158,157,161,156,158,157,155,156,158,158,157,156,158,157,154,155,150,158,156,160,160,160,156,157,154,155,150,159,156,152,156,160,158,157,154,158,158,158,155,156,160,160,155,156,157,158,157,159,157,161,155,152,157,158,154,157,160,156,158,155,158,158,156,155,155,150,154,156,155,158,155,155,157,156,158,154,155,158,162,156,159,158,157,159,154,155,160,157,158,154,155,157,158,159,158,158,157,155,156,159,159,155,155,158,155,155,158,155,160,161,157,159,159,156,155,150,156,155,150,156,157,155,155,158,155,156,159,156,158,162,155,160,154,158,158,158,157,160,156,155,157,152,156,160,158,160,155,158,155,155,157,155,156,159,154,155,157,157,160,159,156,157,162,158,156,157,154,160,157,156,159,159,156,155,159,158,157,156,162,160,158,157,162,157,158,157,157,163,156,156,160,161,154,155,156,159,157,156,158,159,157,155,157,162,157,160,158,159,155,156,155,160,158,157,155,160,159,156,157,157,160,155,157,158,157,157,156,160,155,157,156,157,159,159,160,159,160,157,162,157,157,154,157,157,159,161,155,160,155,155,157,160,156,158,158,161,159,156,156,158,160,160,158,155,157,161,154,160,156,155,156,160,158,156,157,150,155,154,160,157,154,155,155,160,155,154,158,157,155,160,155,156,160,154,157,154,158,157,159,157,155,152,155,156,156,155,155,155,155,156,156,159,159,157,160,155,158,158,157,157,150,155,156,155,156,156,155,159,150,161,155,159,156,156,158,161,155,157,156,159,155,150,155,156,161,155,156,156,154,157,155,157,158,156,158,160,155,161,158,156,159,157,156,159,155,158,162,155,160,158,161,160,156,158,164,156,158,159,158,154,161,158,157,157,156,156,160,157,155,156,160,160,155,158,156,162,160,160,158,157,160,163,156,154,154,162,156,157,155,160,150,158,155,156,154,157,159,160,158,157,162,154,158,163,158,154,158,154,156,155,158,156,159,158,156,156,159,154,159,154,159,156,157,157,160,159,159,156,150,159,158,156,156,156,158,155,158,156,155,156,157,158,156,156,159,157,157,156,156,159,157,160,159,161,159,158,158,160,157,158,156,156,160,160,158,157,157,158,162,150,156,158,158,163,159,158,154,156,159,159,159,157,158,155,161,155,159,155,160,157,156,161,158,157,156,157,158,155,160,158,160,156,157,159,160,156,156,158,156,156,156,155,157,156,156,160,157,154,159,160,157,158,162,159,158,161,158,156,160,156,159,162,162,157,158,160,159,158,160,160,157,156,159,158,160,157,161,158,158,154,160,160,161,154,161,159,156,158,157,160,159,161,157,157,162,156,157,159,152,161,157,158,158,157,158,157,158,158,157,159,159,159,150,157,159,158,151,158,156,160,158,158,157,156,158,158,156,156,158,160,155,159,156,161,156,163,154,161,159,157,159,161,158,157,155,159,156,158,155,161,158,156,161,155,159,158,159,155,162,154,162,161,157,159,159,156,160,157,159,160,160,159,156,156,156,157,157,163,159,161,156,158,156,159,156,157,158,156,160,163,163,156,160,159,157,156,160,160,155,157,155,160,157,160,160,157,158,159,157,159,160,161,160,159,156,158,157,157,156,160,156,162,159,157,154,156,155,162,159,159,161,157,162,159,156,156,156,162,158,161,158,167,159,159,156,158,156,159,157,154,159,160,159,155,163,158,158,162,156,162,158,158,156,161,159,155,160,155,159,150,161,155,156,157,157,155,157,155,163,155,158,157,155,157,161,154,154,155,156,157,159,156,156,159,158,158,158,161,159,156,158,158,158,160,160,162,158,159,156,161,154,154,158,157,161,159,157,159,154,159,161,159,159,160,159,162,160,158,158,157,160,159,161,161,157,158,157,158,162,160,161,159,161,159,162,159,157,161,160,158,160,160,156,157,157,159,159,159,161,158,160,155,157,162,159,162,161,159,161,158,159,162,155,159,161,155,160,157,156,157,160,154,157,159,157,158,160,159,160,157,156,156,158,157,158,154,161,159,154,158,159,160,160,159,162,159,161,158,161,158,156,160,160,158,156,159,158,155,155,156,160,159,162,158,160,159,159,159,156,156,156,164,155,158,157,160,157,160,158,160,158,158,159,152,159,158,157,162,160,160,160,159,155,158,154,159,161,157,160,158,157,154,160,155,158,160,152,156,150,158,157,159,158,162,158,157,157,156,160,159,158,159,155,156,160,154,158,155,156,152,156,156,156,156,154,158,156,157,155,154,156,156,157,156,158,157,156,159,161,152,156,155,152,156,156,155,158,159,157,156,157,156,158,158,155,152,161,159,155,156,157,152,156,158,158,150,155,152,158,159,158,155,160,150,154,156,158,155,157,160,156,157,155,155,157,159,158,156,158,158,156,159,156,157,150,155,158,158,157,158,159,158,150,160,156,157,158,155,154,157,156,156,160,157,161,157,158,158,158,150,150,154,150,150,150,157,157,150,158,155,159,158,158,150,158,159,154,154,157,154,155,157,155,154,155,157,154,157,156,157,158,160,155,159,155,157,160,150,152,156,156,156,154,157,156,154,156,159,154,155,150,150,158,158,156,160,158,152,150,157,154,159,150,150,158,155,154,157,155,154,150,152,156,156,154,159,152,156,156,150,156,156,157,154,152,154,151,155,155,152,158,157,161,152,152,157,154,158,150,156,158,150,157,154,156,154,155,158,156,154,150,154,158,150,159,155,151,152,155,154,154,154,154,152,150,154,154,154,152,150,150,156,150,157,150,151,151,151,155,150,150,158,150,152,155,155,152,150,156,151,152,150,151,158,150,152,152,158,148,154,151,152,154,155,150,154,154,154,155,155,150,150,156,151,155,151,151,151,152,152,150,151,151,151,151,150,156,152,159,148,156,154,150,149,156,152,154,155,150,152,155,151,155,149,150,150,151,155,149,155,150,152,152,149,150,154,151,149,156,154,149,154,151,147,149,150,149,151,154,149,155,151,149,148,150,155,150,149,149,152,148,154,150,149,150,149,151,154,149,152,154,150,150,151,152,155,150,150,151,149,148,152,149};
    
    
    int b[2048]={150,149,143,148,151,151,150,150,149,149,152,148,148,147,146,152,149,150,147,151,150,149,148,149,152,150,148,150,147,149,149,149,149,151,152,151,149,148,151,147,151,147,150,147,151,153,154,153,151,151,151,151,154,154,153,152,148,151,150,148,153,151,149,151,150,156,155,159,158,154,154,151,152,154,155,150,154,149,153,149,154,152,155,150,154,152,155,150,149,154,150,156,154,153,151,153,151,155,151,157,151,152,153,151,148,153,150,157,150,156,153,147,155,150,155,155,152,153,154,151,152,151,153,152,151,157,151,152,153,149,154,152,154,154,151,151,153,153,157,154,154,155,153,155,157,153,152,151,156,151,153,152,152,154,155,153,155,150,150,156,154,149,152,154,154,154,151,150,156,148,150,157,153,154,153,154,154,154,156,150,150,155,156,155,156,154,154,153,154,155,158,151,154,154,153,153,156,151,148,153,151,153,154,153,156,153,154,151,154,153,153,157,154,155,154,157,155,156,152,155,155,157,154,159,156,156,154,155,154,156,156,151,152,153,153,156,154,152,159,150,153,158,153,155,156,155,156,155,155,154,154,154,155,155,155,154,149,156,153,156,153,155,155,156,157,150,157,157,151,157,157,158,152,153,156,155,154,154,155,156,154,154,156,153,157,154,150,157,157,152,155,155,154,154,155,154,156,156,153,155,154,157,155,156,156,153,155,157,154,157,154,161,155,155,155,158,156,156,153,154,155,155,157,157,157,152,155,156,159,155,154,154,155,157,151,159,154,157,154,157,158,154,155,155,155,159,155,156,156,157,154,158,155,160,157,157,158,158,155,158,155,155,155,153,159,156,157,158,156,157,156,154,156,158,157,156,159,156,157,158,155,157,154,157,155,157,156,157,157,159,156,157,156,162,158,155,159,156,156,159,155,157,155,158,155,162,156,157,154,163,157,158,156,161,157,156,157,156,154,158,159,160,156,159,159,157,159,155,162,159,156,155,157,154,155,156,157,156,157,155,159,157,160,153,157,158,152,157,155,154,158,155,158,158,158,155,158,156,156,157,159,156,159,156,157,157,156,156,158,155,155,160,153,158,154,159,157,154,157,155,157,159,154,157,153,155,155,155,152,155,159,158,155,155,158,156,154,154,155,157,157,154,158,155,159,155,160,156,159,157,155,153,160,156,150,154,157,153,158,155,153,154,157,155,158,160,158,154,159,157,157,157,155,156,159,154,157,160,154,155,157,156,153,156,157,156,158,153,156,156,154,157,156,159,158,158,156,155,156,155,156,155,160,155,156,158,157,154,153,158,157,155,157,155,158,156,159,156,157,159,157,156,157,159,154,160,158,158,160,156,155,154,161,159,160,157,156,154,155,154,156,159,158,155,154,153,158,162,156,156,155,154,160,159,162,160,159,158,161,153,159,156,155,160,158,159,158,155,161,155,157,154,154,156,153,156,163,154,149,160,160,155,159,155,156,155,153,157,158,157,157,154,157,155,158,155,156,156,156,155,153,156,157,155,155,155,157,157,157,157,155,157,157,155,159,158,153,156,157,155,158,156,158,155,154,157,157,156,155,156,155,160,157,159,153,158,155,162,157,159,159,155,156,154,155,158,157,161,156,158,157,155,156,158,158,157,156,158,157,154,155,153,158,156,160,160,160,156,157,154,155,153,159,156,152,156,160,158,157,154,158,158,158,155,156,160,160,155,156,157,158,157,159,157,161,155,152,157,158,154,157,160,156,158,155,158,158,156,155,155,153,154,156,155,158,155,155,157,156,158,154,155,158,162,156,159,158,157,159,154,155,160,157,158,154,155,157,158,159,158,158,157,155,156,159,159,155,155,158,155,155,158,155,160,161,157,159,159,156,155,153,156,155,153,156,157,155,155,158,155,156,159,156,158,162,155,160,154,158,158,158,157,160,156,155,157,152,156,160,158,160,155,158,155,155,157,155,156,159,154,155,157,157,160,159,156,157,162,158,156,157,154,160,157,156,159,159,156,155,159,158,157,156,162,160,158,157,162,157,158,157,157,163,156,156,160,161,154,155,156,159,157,156,158,159,157,155,157,162,157,160,158,159,155,156,155,160,158,157,155,160,159,156,157,157,160,155,157,158,157,157,156,160,155,157,156,157,159,159,160,159,160,157,162,157,157,154,157,157,159,161,155,160,155,155,157,160,156,158,158,161,159,156,156,158,160,160,158,155,157,161,154,160,156,155,156,160,158,156,157,153,155,154,160,157,154,155,155,160,155,154,158,157,155,160,155,156,160,154,157,154,158,157,159,157,155,152,155,156,156,155,155,155,155,156,156,159,159,157,160,155,158,158,157,157,153,155,156,155,156,156,155,159,153,161,155,159,156,156,158,161,155,157,156,159,155,153,155,156,161,155,156,156,154,157,155,157,158,156,158,160,155,161,158,156,159,157,156,159,155,158,162,155,160,158,161,160,156,158,164,156,158,159,158,154,161,158,157,157,156,156,160,157,155,156,160,160,155,158,156,162,160,160,158,157,160,163,156,154,154,162,156,157,155,160,153,158,155,156,154,157,159,160,158,157,162,154,158,163,158,154,158,154,156,155,158,156,159,158,156,156,159,154,159,154,159,156,157,157,160,159,159,156,153,159,158,156,156,156,158,155,158,156,155,156,157,158,156,156,159,157,157,156,156,159,157,160,159,161,159,158,158,160,157,158,156,156,160,160,158,157,157,158,162,153,156,158,158,163,159,158,154,156,159,159,159,157,158,155,161,155,159,155,160,157,156,161,158,157,156,157,158,155,160,158,160,156,157,159,160,156,156,158,156,156,156,155,157,156,156,160,157,154,159,160,157,158,162,159,158,161,158,156,160,156,159,162,162,157,158,160,159,158,160,160,157,156,159,158,160,157,161,158,158,154,160,160,161,154,161,159,156,158,157,160,159,161,157,157,162,156,157,159,152,161,157,158,158,157,158,157,158,158,157,159,159,159,153,157,159,158,151,158,156,160,158,158,157,156,158,158,156,156,158,160,155,159,156,161,156,163,154,161,159,157,159,161,158,157,155,159,156,158,155,161,158,156,161,155,159,158,159,155,162,154,162,161,157,159,159,156,160,157,159,160,160,159,156,156,156,157,157,163,159,161,156,158,156,159,156,157,158,156,160,163,163,156,160,159,157,156,160,160,155,157,155,160,157,160,160,157,158,159,157,159,160,161,160,159,156,158,157,157,156,160,156,162,159,157,154,156,155,162,159,159,161,157,162,159,156,156,156,162,158,161,158,167,159,159,156,158,156,159,157,154,159,160,159,155,163,158,158,162,156,162,158,158,156,161,159,155,160,155,159,153,161,155,156,157,157,155,157,155,163,155,158,157,155,157,161,154,154,155,156,157,159,156,156,159,158,158,158,161,159,156,158,158,158,160,160,162,158,159,156,161,154,154,158,157,161,159,157,159,154,159,161,159,159,160,159,162,160,158,158,157,160,159,161,161,157,158,157,158,162,160,161,159,161,159,162,159,157,161,160,158,160,160,156,157,157,159,159,159,161,158,160,155,157,162,159,162,161,159,161,158,159,162,155,159,161,155,160,157,156,157,160,154,157,159,157,158,160,159,160,157,156,156,158,157,158,154,161,159,154,158,159,160,160,159,162,159,161,158,161,158,156,160,160,158,156,159,158,155,155,156,160,159,162,158,160,159,159,159,156,156,156,164,155,158,157,160,157,160,158,160,158,158,159,152,159,158,157,162,160,160,160,159,155,158,154,159,161,157,160,158,157,154,160,155,158,160,152,156,153,158,157,159,158,162,158,157,157,156,160,159,158,159,155,156,160,154,158,155,156,152,156,156,156,156,154,158,156,157,155,154,156,156,157,156,158,157,156,159,161,152,156,155,152,156,156,155,158,159,157,156,157,156,158,158,155,152,161,159,155,156,157,152,156,158,158,150,155,152,158,159,158,155,160,150,154,156,158,155,157,160,156,157,155,155,157,159,158,156,158,158,156,159,156,157,153,155,158,158,157,158,159,158,153,160,156,157,158,155,154,157,156,156,160,157,161,157,158,158,158,153,153,154,153,153,153,157,157,150,158,155,159,158,158,153,158,159,154,154,157,154,155,157,155,154,155,157,154,157,156,157,158,160,155,159,155,157,160,153,152,156,156,156,154,157,156,154,156,159,154,155,153,153,158,158,156,160,158,152,153,157,154,159,153,153,158,155,154,157,155,154,153,152,156,156,154,159,152,156,156,153,156,156,157,154,152,154,151,155,155,152,158,157,161,152,152,157,154,158,153,156,158,153,157,154,156,154,155,158,156,154,153,154,158,153,159,155,151,152,155,154,154,154,154,152,153,154,154,154,152,153,153,156,153,157,153,151,151,151,155,153,153,158,153,152,155,155,152,153,156,151,152,153,151,158,153,152,152,158,148,154,151,152,154,155,153,154,154,154,155,155,153,153,156,151,155,151,151,151,152,152,150,151,151,151,151,150,156,152,159,148,156,154,150,149,156,152,154,155,153,152,155,151,155,149,153,150,151,155,149,155,153,152,152,149,153,154,151,149,156,154,149,154,151,147,149,153,149,151,154,149,155,151,149,148,150,155,150,149,149,152,148,154,153,149,150,149,151,154,149,152,154,153,150,151,152,155,153,150,151,149,148,152,149 };
    MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
    {
    
      ui->setupUi(this);
    
      ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
                                      QCP::iSelectLegend | QCP::iSelectPlottables);
    
      ui->customPlot->axisRect()->setupFullAxesBox();
      
    
      QCPTextElement *title = new QCPTextElement(ui->customPlot, "RGB", QFont("sans", 17, QFont::Bold));
    
      
      ui->customPlot->xAxis->setLabel("x Axis");
      ui->customPlot->yAxis->setLabel("y Axis");
      ui->customPlot->legend->setVisible(true);
    
        addRandomGraph();
      
      ui->customPlot->xAxis->setRange(0, 2048);
      ui->customPlot->yAxis->setRange(0, 255);
      
      t1=new QTimer(this);
      connect(t1,SIGNAL(timeout()),this,SLOT(timer_slot()));
      t1->start(0);
    
    }
    
    
    MainWindow::~MainWindow()
    {
      delete ui;
    }
    
    void MainWindow::timer_slot()
    {
    
        QVector<double> x(2048), y(2048);
        for (int i=0; i<2048; i++)
        {
         if(xx==0)
         {
          x[i] = i;
          y[i] = a[i] ;
         }
         else
         {
            x[i] = i;
           y[i] = b[i] ;
         }
        }
        if(xx>1)
            xx=0;
        else
            xx+=1;
         ui->customPlot->graph()->setData(x, y);
    ui->customPlot->replot();
    
    }
    
    void MainWindow::addRandomGraph()
    {
      int n = 2048; // number of points in graph
    
      QVector<double> x(n), y(n);
      for (int i=0; i<n; i++)
      {
       if(xx==0)
       {
        x[i] = i;
        y[i] = a[i] ;
       }
       else
       {
          x[i] = i;
         y[i] = b[i] ;
       }
      }
      if(xx>1)
          xx=0;
      else
          xx+=1;
    
      ui->customPlot->addGraph();
      ui->customPlot->graph()->setData(x, y);
      ui->customPlot->replot();
    }
    
    void MainWindow::removeSelectedGraph()
    {
      if (ui->customPlot->selectedGraphs().size() > 0)
      {
        ui->customPlot->removeGraph(ui->customPlot->selectedGraphs().first());
        ui->customPlot->replot();
      }
    }
    
    void MainWindow::removeAllGraphs()
    {
      ui->customPlot->clearGraphs();
      ui->customPlot->replot();
    }
    
    
    
    
    
    
    
    
    
    
    

  • Lifetime Qt Champion

    Hi,

    I would say: less update. From what I can see you have a QTimer that fires non stop as fast as possible which is not the best way to handle updates.



  • @SGaist is there any way if you have please share...i am struggling from pas 1 week



  • @SGaist actually i am receiving data on Ethernet and storing to byte array and the byte array continuously updating based on that i need to update graph also.
    byte array length is 2048. i tried lot its showing flickering .
    please i need help


  • Lifetime Qt Champion

    As I already wrote you have a QTimer that is literally spamming the event loop to update your plot which is wrong. Do smart updates. Human eyes are still working at 24fps so there's not need to try to refresh your plot at light speed.



  • @SGaist actually the whole graph is updating .
    individual point update not happening



  • @SGaist if set my timer 100 there is no flicker.but when ever the array content changes graph also needs to change.that change not happening smoothly(transition form old values of array to new values array )


  • Lifetime Qt Champion

    How much data are your receiving ?
    How fast ?
    What is it representing ?



  • @SGaist I am reading line camera pixel values.
    1.Each line is 2048 pixel (in the form RGB888)
    2.The data are reading through ETHERNET(tcp/ip) protocal
    3.I need to plot the graph(RGB) based on the received data.
    4.Speed is 100mbps
    5.its representing pixel intensity


  • Lifetime Qt Champion

    How are you bringing these data to your application ?



  • @SGaist Reading it from a line scan sensor .(interface :ethernet)



  • This post is deleted!


  • @swansorter Graph points not changing from present points to updated points (smooth transition),instead the whole graph is changing
    ezgif.com-resize.gif


  • Lifetime Qt Champion

    @swansorter said in QT QCUSTOM plot flickering problem:

    @SGaist Reading it from a line scan sensor .(interface :ethernet)

    I understand the hardware you are using, my question is what are you using at the software layer to get the data ?

    From the looks of your code you are just replacing all the data so I don't know how you can expect a smooth transition.



  • testing purpose only i used two array .
    if it is works then i ill updated to ethernet code(RTP Protocal)


  • Lifetime Qt Champion

    As I wrote before, you are literally replacing the values. If you want a smooth transition, you will have to write yourself the intermediate values to go from one list to the other.



  • @SGaist if use random generator it works fine
    points.append(QPointF(k , qrand() % ((10 + 1) - 5) + 5));
    if i replace array values its not working?
    sir if have the code for intermediate values please share.i want to change the values of dynamically.


  • Lifetime Qt Champion

    @swansorter said in QT QCUSTOM plot flickering problem:

    @SGaist if use random generator it works fine
    points.append(QPointF(k , qrand() % ((10 + 1) - 5) + 5));

    How are you using that comparing to your array implementation ?



  • No just checked example program and implemented it .
    Instead of array values i used that random generator.



  • @SGaist each cycle array values are changing and and in random generator changes on evry cycle


  • Lifetime Qt Champion

    You should rather concentrate on actual real data or at least use realistic test data. Using just two tables does not reflect reality and what you will get from your device.


Log in to reply