PDA

View Full Version : error: expected class-name before "{" token



freekill
9th January 2010, 07:25
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

Tanuki-no Torigava
9th January 2010, 07:59
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.

freekill
9th January 2010, 10:32
So here's what I came up with my webcam.h:


#ifndef WEBCAM_H
#define WEBCAM_H

#include <QWaitCondition>
#include <QWidget>
#include "ui_webcam.h"

class CapturingThread;
class ImageBuffer;
class RenderingThread;

class WebcamWidget : public QWidget
{
Q_OBJECT

public:
WebcamWidget(QWidget *parent=0);
~WebcamWidget();

protected:
void paintEvent(QPaintEvent* event);

private slots:
void startThreads();
void haltThreads();
void updatePixmap(QImage& image);

private:
Ui::webcam ui;
CapturingThread* capturingThread;
ImageBuffer* imageBuffer;
RenderingThread* renderingThread;
QPixmap pixmap;
QWaitCondition waitCondition;
QWaitCondition* pWaitCondition;
};

#endif


This time, flagged me 2 errors.
error: using-declaration for non-member at class scope
error: expected ";" before "ui"

Rembobo
9th January 2010, 11:11
Explore/show ui_webcam.h file. Imho there is no Ui::webcam class.

Tanuki-no Torigava
9th January 2010, 13:35
Or it should be something like:
webcam ui;

freekill
9th January 2010, 16:34
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.