Qt-interest Archive, October 2006
Trouble with Q_OBJECT
Message 1 in thread
I have a simple custom widget, PictureWidget which displays images in a
certain way. The widget supports dropping of image urls. To let the app
containing the widget know an image was dropped, I added a signal. Now it
gives me the error:
undefined reference to `vtable for PictureWidget'
If I comment out the Q_OBJECT macro, it compiles and runs, but of course I
can't emit a signal. I can implement without signals but that couples it to
the application. Here is the header if anyone has any ideas. I can send the
implementation and a main if anybody wants to try it.
Mike
***************************
#ifndef PICTUREWIDGET_H
#define PICTUREWIDGET_H
#include <QLabel>
#include <QImage>
#include <QDropEvent>
#include <QString>
class PictureWidget : public QLabel
{
//Q_OBJECT
public:
PictureWidget (QWidget *parent);
void setImage (const QImage &image);
protected:
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void paintEvent (QPaintEvent *event);
signals:
void picDropped(QString fPath);
private:
void drawIt(QPainter &painter);
QImage image;
QString filePath;
};
#endif
**************************************
--
[ signature omitted ]
Message 2 in thread
Your probably not using qmake.
This error usually occurs when your not compiling the moc generated
files
Scott
> -----Original Message-----
> From: Mike Adolf [mailto:mlnx@xxxxxxx]
> Sent: Sunday, October 22, 2006 6:58 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Trouble with Q_OBJECT
>
> I have a simple custom widget, PictureWidget which displays images in
a
> certain way. The widget supports dropping of image urls. To let the
app
> containing the widget know an image was dropped, I added a signal.
Now it
> gives me the error:
>
> undefined reference to `vtable for PictureWidget'
>
> If I comment out the Q_OBJECT macro, it compiles and runs, but of
course I
> can't emit a signal. I can implement without signals but that couples
it
> to
> the application. Here is the header if anyone has any ideas. I can
send
> the
> implementation and a main if anybody wants to try it.
>
> Mike
>
> ***************************
> #ifndef PICTUREWIDGET_H
> #define PICTUREWIDGET_H
>
> #include <QLabel>
> #include <QImage>
> #include <QDropEvent>
> #include <QString>
>
> class PictureWidget : public QLabel
> {
> //Q_OBJECT
>
> public:
> PictureWidget (QWidget *parent);
> void setImage (const QImage &image);
>
> protected:
> void dropEvent(QDropEvent *event);
> void dragEnterEvent(QDragEnterEvent *event);
> void paintEvent (QPaintEvent *event);
>
> signals:
> void picDropped(QString fPath);
>
> private:
> void drawIt(QPainter &painter);
> QImage image;
> QString filePath;
> };
>
> #endif
> **************************************
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Message 3 in thread
On Sunday 22 October 2006 20:17, Scott Aron Bloom wrote:
I neglected to rerun qmake to make a new makefile after I add the code and
macro for signals.
Thanks for your help,
Mike
> Your probably not using qmake.
>
> This error usually occurs when your not compiling the moc generated
> files
>
> Scott
>
> > -----Original Message-----
> > From: Mike Adolf [mailto:mlnx@xxxxxxx]
> > Sent: Sunday, October 22, 2006 6:58 PM
> > To: qt-interest@xxxxxxxxxxxxx
> > Subject: Trouble with Q_OBJECT
> >
> > I have a simple custom widget, PictureWidget which displays images in
>
> a
>
> > certain way. The widget supports dropping of image urls. To let the
>
> app
>
> > containing the widget know an image was dropped, I added a signal.
>
> Now it
>
> > gives me the error:
> >
> > undefined reference to `vtable for PictureWidget'
> >
> > If I comment out the Q_OBJECT macro, it compiles and runs, but of
>
> course I
>
> > can't emit a signal. I can implement without signals but that couples
>
> it
>
> > to
> > the application. Here is the header if anyone has any ideas. I can
>
> send
>
> > the
> > implementation and a main if anybody wants to try it.
> >
> > Mike
> >
> > ***************************
> > #ifndef PICTUREWIDGET_H
> > #define PICTUREWIDGET_H
> >
> > #include <QLabel>
> > #include <QImage>
> > #include <QDropEvent>
> > #include <QString>
> >
> > class PictureWidget : public QLabel
> > {
> > //Q_OBJECT
> >
> > public:
> > PictureWidget (QWidget *parent);
> > void setImage (const QImage &image);
> >
> > protected:
> > void dropEvent(QDropEvent *event);
> > void dragEnterEvent(QDragEnterEvent *event);
> > void paintEvent (QPaintEvent *event);
> >
> > signals:
> > void picDropped(QString fPath);
> >
> > private:
> > void drawIt(QPainter &painter);
> > QImage image;
> > QString filePath;
> > };
> >
> > #endif
> > **************************************
> >
> > --
> > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> > "unsubscribe" in the subject or the body.
> > List archive and information: http://lists.trolltech.com/qt-interest/
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]