Zoom Crash Bug for Qt Spectrogram



  • Hello All,
    I have fixed many of the performance issues on my program, but now I am encountering a crash anytime I attempt to zoom in on the data on my spectrogram. I am using Qt Charts, and there is an exception thrown when I zoom in that says I am dividing by zero. Does anyone know what may cause this issue, or how I would go about locating the bug in my program? I am new to Qt, so bear with me.

    Joseph


  • Moderators

    @Yippiyak To locate a bug in your program you should use the debugger (from QtCreator). Also you can show the code where you do the zooming.



  • @jsulm
    So I did some debugging and I figured out that this function:

    void WaterfallDisplay::resetImage()
    {
    m_image = QImage();
    }

    which was intended to reset the image upon zooming in, returns a division by zero error elsewhere in the code, as it reduces the height to 0. Any idea on a way I can reset the image, but prevent the height from getting messed up?


  • Lifetime Qt Champion

    Hi,

    You can try with:

    m_image = QImage(1, 1, m_image.format());
    


  • @SGaist
    Youre the GOAT!
    That worked for the most part, but incase someone else stumbles upon this thread here was my final implementation:

    void WaterfallDisplay::resetImage()
    {
    m_image = QImage(m_image.width(),m_image.height(), m_image.format());
    m_image.fill(QColor(0,0,0,0));
    m_currentDrawingLine = 0;
    m_linesDrawn = 0;
    m_pastOneScreen = false;

    m_startTimer = true;
    }


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.