[SOLVED]The program has unexpectedly finished.

  • My program crashes when I call this method. I'm trying to make graphic effect on an image.

    void MainWindow::stripesOk()
        int nodeHeight = stripesDialog->nodeHeight;
        double division = imageObject->height() / nodeHeight;
        int totalNodes = qFloor(division);
        targetImage = new QImage(imageObject->size(), QImage::Format_ARGB32);
        painter = new QPainter(targetImage);
        for(int i = 0;i < totalNodes; i++)
            int x = 0;
            int y = i * nodeHeight;
            int width = imageObject->width();
            int shift = stripesDialog->shift;
            int a = shift - (2 * shift);
            int b = shift;
            int randomShift = randomInterval(a,b);
        imageObject = targetImage;

  • Qt Champions 2016


    Hi its hard to guess. You are 100% sure nodeHeight is not zero ?

    Also if you start with debug, and place break point at first line, you can single step and see
    which line that does the crash.

  • thanks, the variables were not being set properly, so they were at 0 indeed.

    the program is not crashing anymore, but I am only getting a blank image.

  • I think you may be using painter->drawImage wrong. try using the defualt values for all the params except the first 3. then see what happens.

  • Lifetime Qt Champion


    Did you check the value of totalNodes ? Does the variables you use for drawImage have meaningful values ?

    By the way, why allocate your QImage object on the heap ? That's not needed, furthermore, from the looks of it, you have a memory leak since you don't delete imageObject before replacing it with targetImage.

  • solved, had to check another variable . thanks all

Log in to reply

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