Issue with my dice roller.



  • I am working on developing a dice roller when I compile and run my prog under qt I get beautiful resultsworking. However when I compile and run outside of QT I get the following broken

    here is the pertinent code to the message box and random number generator.

    void MainWindow::on_pushButton_clicked()
    {
    int rollResults[numD][numR];
    int results[numD];
    int i;
    for(i=0;i<numR;i++)
    {
    dice die;
    die.roll(numD,numS,results);
    int j;
    for (j=0;j<numD;j++)
    {
    rollResults[i][j]=results[j];
    }
    }
    QString txt;
    for(i=0;i<numR;i++)
    {
    int j,total=0;
    for (j=0;j<numD;j++)
    {
    QString t;
    t.setNum(rollResults[i][j]);
    txt+=t;
    txt+=" ";
    total+=rollResults[i][j];
    }

        QString tx="<br>", tot;
        tot.setNum(total);
        total=0;
        txt+="= " + tot + tx;
    
    }
    QMessageBox msg;
    msg.Ok;
    msg.setText(txt);
    msg.exec();
    

    }

    Dice roller
    void dice::roll(int dNum, int dSide, int *array)
    {
    int i;

    for(i=0; i<dNum; i++)
    {
    
        array[i] = rand() % dSide + 1;
        qDebug()<<array[i];
    
    }
    return;
    

    }


  • Qt Champions 2016

    Hi
    The image upload is broken here. Please use external site and post links.

    We cant see what you mean else :)


Log in to reply
 

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