Results 1 to 5 of 5

Thread: QList err : expected primary-expression before ‘)’ token

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Location
    UK
    Posts
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QList err : expected primary-expression before ‘)’ token

    Hi all
    Please for support and help
    Thanks in advance!
    Qt Code:
    1. my list in .h file
    2.  
    3. QList < FilmDoc > * pDocList;
    4.  
    5. void FilmApp::openDocumentFile (const char *file)
    6. {
    7. statusBar ()->message (tr ("Opening file..."));
    8.  
    9. QList <FilmDoc> doc = *pDocList;
    10.  
    11. // if this might help function has to check if file is already opened
    12. // and if yes then setFocus to opened view
    13. for ( int i = 0; i < doc.size (); ++i ) {
    14. if ( doc.contains ( doc& ) == file ){// this line generate err
    15.  
    16. FilmView * view = doc->firstView ();
    17. view->setFocus ();
    18. return;
    19. }
    20. }
    21. ...
    22. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QList err : expected primary-expression before ‘)’ token

    doc.contains ( doc& ) makes no sense.
    you probably want:
    Qt Code:
    1. if(doc.at(i) == file){
    2. ...
    3. }
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Dec 2010
    Location
    UK
    Posts
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QList err : expected primary-expression before ‘)’ token

    thx but this code is generating msg;

    "error: no match for ‘operator==’ in ‘doc.QList<T>::at [with T = FilmDoc](i) == file’
    candidates are: bool operator==(QBool, bool)
    ...
    and much more of this
    "

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QList err : expected primary-expression before ‘)’ token

    it means that FilmDoc has no '==' operator.
    You will have to compare some property of FilmDoc to make sure you have the one you need.
    If there is no such property, you will have to implement the '==' operator.
    But you probably can get away with storing pointers, which you can compare, and they are unique per item.
    QList<FilmDoc *> myList;
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. expected `)' before '*' token
    By vinod sharma in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2010, 07:57
  2. Expected class-name before '{' token
    By imagiro1 in forum Newbie
    Replies: 16
    Last Post: 16th June 2009, 11:37
  3. error: expected class-name before '{' token
    By Aresti in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2008, 20:00
  4. Replies: 3
    Last Post: 10th November 2008, 16:14
  5. expected initializer before »)« token
    By Holy in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2008, 16:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.