PDA

View Full Version : What's wrong with my GMCButton?



jiveaxe
8th November 2007, 09:38
Hi,
I have almost completed my application and now I am working on restyling the gui. I started creating a new GMCButton like this:


class GMCButton: public QPushButton
{
Q_OBJECT

public:
GMCButton(QWidget *parent = 0);
};

then in my centralwidget.cpp

searchButton = new GMCButton(tr("&Open search dialog"));

During compilation I got this error:


mainwindow.cpp: In constructor ‘MainWindow::MainWindow()’:
mainwindow.cpp:41: error: no matching function for call to ‘MainWindow::connect(GMCButton*&, const char [11], MainWindow* const, const char [20])’
/usr/include/qt4/QtCore/qobject.h:191: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/usr/include/qt4/QtCore/qobject.h:292: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const

in correspondence of this line (in mainwindow.cpp):


connect(centralWidget->searchButton, SIGNAL(clicked()), this, SLOT(viewSearchDialog()));

Why this error?

Regards

jpn
8th November 2007, 09:53
Try including "gmcbutton.h" in "mainwindow.cpp".

jiveaxe
8th November 2007, 09:59
Oops, what stupid error... :o

Thanks

jiveaxe
8th November 2007, 10:33
Now I am afraid to post a new potentially stupid question, but I do it:

After correcting the code as jpn said, now at the and of compilation I got this error:

gmcwidgets.cpp:5: undefined reference to `vtable for GMCButton'

The incriminated code is:


GMCButton::GMCButton(QWidget *parent, QString text)
:QPushButton(parent)
{
setFixedHeight(28);
setText(text);
}

line 5 is :QPushButton(parent)

The updated GMCButton class is:


class GMCButton: public QPushButton
{
Q_OBJECT

public:
GMCButton(QWidget *parent = 0, QString text = "");
};

Thanks

EDIT: The problem is gone alone.

jpn
8th November 2007, 11:02
Now I am afraid to post a new potentially stupid question, but I do it:
...
gmcwidgets.cpp:5: undefined reference to `vtable for GMCButton'

Heh, there is no need to be afraid but search the forums always before asking, please. This is one of the most common errors while compiling Qt applications. This has been asked and answered tons of times on the forums. Just try searching for "vtable".. ;)