Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-21907

Cannot construct QQueue this way: QQueue<int>() << 2 << 3;

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P5: Not important
    • None
    • 4.7.4, 5.1.0 RC1
    • None
    • Windows 7 x64

    Description

      If you want to construct a QList "inline" and send it as an argument to a function, it looks like this:

       
      (...)
      fooFunction(QList<int>() << 1 << 2 << 3 << 10);
      (...)
      

      but you cannot do the same thing with QQueue, though it subclasses QList:

      void function(QQueue<int> queue) {
          return;
      }
      
      int main(int argc, char *argv[])
      {
      //    QQueue<int> queue;
      //    queue.enqueue(2);
      //    queue.enqueue(4);
      //    function(queue); // this and the above will compile, but it's more cumbersome to write
      
          function(QQueue<int>() << 2 << 4); // this wont compile
      
          return 0;
      }
      

      Is it an expected behavior or a bug? I'd really like to be able to construct QQueues like QLists.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            phan Dominik Dera
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes