Zoom Crash Bug for Qt Spectrogram
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.
@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.
So I did some debugging and I figured out that this function:
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?
You can try with:
m_image = QImage(1, 1, m_image.format());
Youre the GOAT!
That worked for the most part, but incase someone else stumbles upon this thread here was my final implementation:
m_image = QImage(m_image.width(),m_image.height(), m_image.format());
m_currentDrawingLine = 0;
m_linesDrawn = 0;
m_pastOneScreen = false;
m_startTimer = true;