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. Missing template argument before "*" token
Forum Updated to NodeBB v4.3 + New Features

Missing template argument before "*" token

Scheduled Pinned Locked Moved General and Desktop
9 Posts 6 Posters 8.7k 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.
  • M Offline
    M Offline
    mkcerusky
    wrote on 30 Nov 2011, 21:56 last edited by
    #1

    I have this line of code in two different classes, in similar positions:

    @
    QList * tmp = new QList(lalgExpressionText.split("+"));
    @

    In one case it works perfectly, in another case i get the error mentioned in the subject, is there a reason for this?
    What does such error mean?
    Actually what I need is only to split a string into a list on which I can iterate and do things, if you have other straightforward ways to do it feel free to suggest.

    Please consider that i am a perfect newbye to QT and quite newbye to c++. My programming experience includes basically only php, javascript and LPC (the old object oriented language used in MUDs!). Thus I understand that my questions might seem odd to experts. Thanks in advance.

    [EDIT: code formatting, Volker]

    1 Reply Last reply
    0
    • L Offline
      L Offline
      LarsG
      wrote on 1 Dec 2011, 00:11 last edited by
      #2

      QList is a template class, (see http://www.cplusplus.com/doc/tutorial/templates/)

      So you have to define which type of variables it works with ie. two variables of type QList<QString> or QList<int> are a list of qstrings and a list of integers you can't have a pointer to list without knowing what kind of pointer, afaik.

      I guess you observe the different behavior because QList* is a critical error and it never goes to the next point, although if only a line seperates them in a file my compiler would give both as an error.

      for your problem I would use something like
      @
      foreach(QString x, QString("My, String").split(',)) {
      qDebug() << "A part is: " << x;
      }
      @

      Note that foreach is a qt specific language construct but is kinda like for(int i=0; i<10;++i) etc..

      1 Reply Last reply
      0
      • V Offline
        V Offline
        veeeee_d
        wrote on 1 Dec 2011, 05:53 last edited by
        #3

        I believe you meant QStringList, not QList.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on 1 Dec 2011, 17:40 last edited by
          #4

          Additionally: Why do you work with a QList allocated on the heap? That's hardly ever necessary!

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mkcerusky
            wrote on 7 Oct 2012, 15:16 last edited by
            #5

            [quote author="Volker" date="1322761234"]Additionally: Why do you work with a QList allocated on the heap? That's hardly ever necessary![/quote]

            What does "allocated on the heap" means?

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lgeyer
              wrote on 8 Oct 2012, 05:35 last edited by
              #6

              http://www.learncpp.com/cpp-tutorial/79-the-stack-and-the-heap/

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mkcerusky
                wrote on 5 May 2013, 17:24 last edited by
                #7

                I see....well, actually I just need to create a list of lists, or vector of vectors, or array of arrays, or whatever. But it seems to be impossible in QT: if i use QLists, then they cannot contain QLists, but they can contain only other types, like qstrings or or int or other, and as I understand it, Qlists can only contain a type of objects at once.
                I wonder if in QT it exists the possibility to create lists of multiple types of objects, included lists.
                Or maybe it is possible to create multidimentional lists?

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mkcerusky
                  wrote on 5 May 2013, 17:26 last edited by
                  #8

                  Or in other words, can containers contain containers?

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    JohanSolo
                    wrote on 6 May 2013, 06:38 last edited by JohanSolo
                    #9

                    Or in other words, can containers contain containers?

                    Sure they can! QVector< int > is a type for instance:

                    QVector< QVector< int > >
                    

                    or

                    QList< QHash< unsigned, QWidget* > >
                    

                    are perfectly legal.

                    PS: After a second reading of your question, a container in general cannot contain multiple types (i.e. you cannot mix doubles and int), however using polymorphism you can do it, by storing pointers. But I'm not sure this was your question.

                    `They did not know it was impossible, so they did it.'
                    -- Mark Twain

                    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