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. [SOLVED] Pass QList with undefined size

[SOLVED] Pass QList with undefined size

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.5k Views 1 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.
  • D Offline
    D Offline
    david.luggen
    wrote on last edited by
    #1

    Hey there

    I'm afraid that this isn't working anyway, but maybe somebody has a good idea.

    I'm looking for the possibility to pass a QList Array to a function as a parameter. So far everything is fine. But now, the point is, I don't know how big the array is and so I can't do further actions with the data. Below a little example:

    @
    void MyFunction(QList<int> passedList[])
    {
    myList[0] = passedList[0];
    myList[1] = passedList[1];
    ...
    }
    @

    This is how it works, but therefore I need to know how big the passed list is going to be. How could this be achieved without that information?

    1 Reply Last reply
    0
    • ZlatomirZ Offline
      ZlatomirZ Offline
      Zlatomir
      wrote on last edited by
      #2

      When you pass an c-style array to a function add another parameter and pass the size too.
      Also you can use another QList and pass a QList<QList<int> > param and then you don't need to pass the size anymore.

      https://forum.qt.io/category/41/romanian

      1 Reply Last reply
      0
      • D Offline
        D Offline
        david.luggen
        wrote on last edited by
        #3

        QList in a QList, already tried, didn't worked and why. Because of the space between > and >. True story! : )
        Thx!

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

          Yeap, compilers require you to write @QList<QList<int> >@ because ">>" is an operator and the compilers are too stupid to distinguish between those two meanings. That is a well known pitfall.

          This was changed in the new C++11 standard by the way.

          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