Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issue with my dice roller.
Forum Updated to NodeBB v4.3 + New Features

Issue with my dice roller.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 566 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elrin
    wrote on last edited by
    #1

    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;
    

    }

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

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

      We cant see what you mean else :)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved