Congratulations to our 2022 Qt Champions!

PieChart [QWidget] - Error: SIGFPE Arithmetic Problem [C++]

  • Dear Qt Community.

    The problem I think is within my loops,when I try to change the color of my brush to a random colour. I did try to change the resultV and other arithmetic variables doesn`t help. I have a SIGFPE Arithemetic problem then Qt informs me of 'Signal Recieved' , the inferior stopped because it recieved a signal from the operating system . Signal name : ? , Signal meaning: unknown.

    Please can anyone kindly help me? [I did have problems with Qt before and had to reinstall it because my main class could not detect it`s files. I am using the lastest version of Qt] .Any help is much appreciated.


    1. 360/sum changed to 'sum/360;' [Fixes SIGFPE Arithmetic Problem]


    1. My codes breakpoint stops at the empty method:
      PieChartWidget::PieChartWidget(QWidget *parent) : QWidget(parent)

    Code: [piechartwidget.cpp]

    #include "piechartwidget.h"

    #include <QColor>
    #include <QPainter>

    PieChartWidget::PieChartWidget(QWidget *parent) : QWidget(parent)


    void PieChartWidget::paintEvent(QPaintEvent *)
    QVector<int> vector(5);

    int sum=0;
    int angleV=0;
    int resultV=0;
    int resultVV =0;
    QPainter painter(this);
    QRectF size = QRectF(10,10,this->width()-10,this->width()-10);
    int *data =;
    for (int i = 0; i < 5; ++i){
        sum += data[i];
    angleV = sum/360;
    for (int i = 0; i < 5; ++i){
        if(i == 0){
            resultV = data[i] * angleV;
            painter.drawPie(size , 0 , resultV*16);
         else {
            resultV = data[i] * angleV;
            resultVV = data[i-1] * angleV;
            painter.drawPie(size , resultVV*16 , resultV*16);


  • Lifetime Qt Champion

    Good you fixed the SIGFPE, but im not sure why its an issue
    it stops at the constructor?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    @NovaPrimera said in PieChart [QWidget] - Error: SIGFPE Arithmetic Problem [C++]:

    360/sum changed to 'sum/360;' [Fixes SIGFPE Arithmetic Problem]

    You know that these two statements are not equivalent ? A division is not a permutative operation.

    What you need to do here is check that sum is not zero and if it is, don't do the division.

  • @SGaist Thank you,Sir that was my problem all along.

Log in to reply