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. Help using QVarLengthArray to store matrix data and how to display it
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 452 Views
  • 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
    Ed0o6
    wrote on last edited by
    #1

    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

    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