Help using QVarLengthArray to store matrix data and how to display it



  • Hi, I am writing a programme that generates a matrix (size determined by the user) filled with random numbers within a maximum value and a minimum value (also determined by the user) I am using QVarLengthArray since it is a very simple matrix with only integers inside it, but the thing is I do not know how to fill each value of the matrix using QVar or how to print them out, I was fine using C++ with a Single dimension array and "cout" but for this I am having issues, labels do not display arrays (and if they do, please tell me how)

    This is what I declared as the matrix
    @
    QVarLengthArray<int> array(c*r);
    @

    c is the input for columns and r is the input for rows (from spinboxes) that will declare the total size of the array, the main question is: how do I fill this array with values that will come from the random number generator???? with arrays is as simple as a cycle for the value of the brackets, but I am new to Qt and really want to learn and improve

    this is the random number generator by the way, it works fine for what I want

    @
    QTime time = QTime::currentTime();
    qsrand((uint)time.msec());
    random = qrand() % ((M + 1) - m) + m;
    @

    Where M is the maximum value of the number and m is the minimum one

    Also, after I print the values into the array, how to print them out on the screen for the user to see? and if you can also guide me into this, how do I print the matrix out into a notepad file???

    Thanks for any help you can provide


Log in to reply
 

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