Results 1 to 6 of 6

Thread: error: expected class-name before "{" token

  1. #1
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default error: expected class-name before "{" token

    I'm getting this compile-time error pointing to the widget class that I inherited from QWidget. I only recycled the previous code I was using I don't know why I'm getting this error.

    In the file included from main.cpp:2:
    webcam.h:13: error: expected class-name before "{" token

    Attached are the files main.cpp and webcam.h
    Attached Files Attached Files

  2. #2
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: error: expected class-name before "{" token

    Both QWidget and Ui::webcam are QObject children while you can inherit from 1 QObject only (inheritance from multiple QObject's will not work ). You can try to encapsulate Ui::webcam as member.
    -- Tanuki

    per cauda vel vaculus cauda

  3. #3
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: error: expected class-name before "{" token

    So here's what I came up with my webcam.h:
    Qt Code:
    1. #ifndef WEBCAM_H
    2. #define WEBCAM_H
    3.  
    4. #include <QWaitCondition>
    5. #include <QWidget>
    6. #include "ui_webcam.h"
    7.  
    8. class CapturingThread;
    9. class ImageBuffer;
    10. class RenderingThread;
    11.  
    12. class WebcamWidget : public QWidget
    13. {
    14. Q_OBJECT
    15.  
    16. public:
    17. WebcamWidget(QWidget *parent=0);
    18. ~WebcamWidget();
    19.  
    20. protected:
    21. void paintEvent(QPaintEvent* event);
    22.  
    23. private slots:
    24. void startThreads();
    25. void haltThreads();
    26. void updatePixmap(QImage& image);
    27.  
    28. private:
    29. Ui::webcam ui;
    30. CapturingThread* capturingThread;
    31. ImageBuffer* imageBuffer;
    32. RenderingThread* renderingThread;
    33. QPixmap pixmap;
    34. QWaitCondition waitCondition;
    35. QWaitCondition* pWaitCondition;
    36. };
    37.  
    38. #endif
    To copy to clipboard, switch view to plain text mode 

    This time, flagged me 2 errors.
    error: using-declaration for non-member at class scope
    error: expected ";" before "ui"
    Last edited by freekill; 9th January 2010 at 10:36.

  4. #4
    Join Date
    Mar 2006
    Posts
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: expected class-name before "{" token

    Explore/show ui_webcam.h file. Imho there is no Ui::webcam class.

  5. The following user says thank you to Rembobo for this useful post:

    freekill (9th January 2010)

  6. #5
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: error: expected class-name before "{" token

    Or it should be something like:
    Qt Code:
    1. webcam ui;
    To copy to clipboard, switch view to plain text mode 
    -- Tanuki

    per cauda vel vaculus cauda

  7. #6
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: error: expected class-name before "{" token

    Quote Originally Posted by Rembobo View Post
    Explore/show ui_webcam.h file. Imho there is no Ui::webcam class.
    So I see. I didn't name the Ui webcam it was Ui::camWidget. This is what flagged me the error. Thanks.

Similar Threads

  1. Replies: 3
    Last Post: 26th April 2009, 17:54
  2. error: expected class-name before '{' token
    By Aresti in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2008, 20:00
  3. Replies: 3
    Last Post: 10th November 2008, 16:14
  4. Replies: 4
    Last Post: 22nd February 2008, 19:08
  5. Replies: 2
    Last Post: 30th January 2008, 20:06

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
  •  
Qt is a trademark of The Qt Company.