Qt-interest Archive, December 2007
undefined ref to vtable :((
Message 1 in thread
Hi all,
my attempts to subclass a ui drive me crazy. I'm sure I just don't see the
point. Can someone help me out?
BR
Eckhard
I have a widget defined as requirement.ui
uic produces ui_requirement.h as expected having:
------
namespace Ui {
class Requirement: public Ui_Requirement {};
} // namespace Ui
--------
in the end.
now I have requirement.h as:
--------
#include "ui_requirement.h"
class Req : public QWidget, private Ui::Requirement
{
Q_OBJECT
public:
Req(QWidget *parent =0);
};
--------
and requirement.cpp as:
--------
#include "requirement.h"
Req::Req(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
}
--------
giving the linker error:
----------
requirement.cpp: undefined refernece to vtable for Req
--
[ signature omitted ]
Message 2 in thread
On 23.12.07 12:16:23, Eckhard Jokisch wrote:
> Hi all,
> my attempts to subclass a ui drive me crazy. I'm sure I just don't see the
> point. Can someone help me out?
I like these beginner errors :)
> --------
> #include "ui_requirement.h"
Here you're missing the QWidget include, thats why moc doesn't run on
this header and you get those undefined references.
Andreas
--
[ signature omitted ]
Message 3 in thread
Andreas Pakulat wrote:
> On 23.12.07 12:16:23, Eckhard Jokisch wrote:
>> Hi all,
>> my attempts to subclass a ui drive me crazy. I'm sure I just don't see
>> the point. Can someone help me out?
>
> I like these beginner errors :)
>
>> --------
>> #include "ui_requirement.h"
>
> Here you're missing the QWidget include, thats why moc doesn't run on
> this header and you get those undefined references.
>
> Andreas
>
Thanks for the hint. It was not the missing include as it was already
included within the ui_*h file.
But it gave me the right track. Kdevelop didn't remove the Makefile by doing
make clean. As I removed it a new Makefile appered and everything was
fine :)
Eckhard
--
[ signature omitted ]
Message 4 in thread
On 23.12.07 12:48:50, Eckhard Jokisch wrote:
> Andreas Pakulat wrote:
>
> > On 23.12.07 12:16:23, Eckhard Jokisch wrote:
> >> Hi all,
> >> my attempts to subclass a ui drive me crazy. I'm sure I just don't see
> >> the point. Can someone help me out?
> >
> > I like these beginner errors :)
> >
> >> --------
> >> #include "ui_requirement.h"
> >
> > Here you're missing the QWidget include, thats why moc doesn't run on
> > this header and you get those undefined references.
> >
> > Andreas
> >
> Thanks for the hint. It was not the missing include as it was already
> included within the ui_*h file.
> But it gave me the right track. Kdevelop didn't remove the Makefile by doing
> make clean. As I removed it a new Makefile appered and everything was
> fine :)
Hmm, when you change the project and add a .ui file (or a normal c++
fle) make should re-run qmake to regenerate the Makefile. At least it
does over here.
And make clean never removes the Makefile, thats the purpose of the
distclean-target, but I'm not sure wether QMake generates such a target.
Andreas
--
[ signature omitted ]
Message 5 in thread
Andreas Pakulat wrote:
>
> Hmm, when you change the project and add a .ui file (or a normal c++
> fle) make should re-run qmake to regenerate the Makefile. At least it
> does over here.
>
> And make clean never removes the Makefile, thats the purpose of the
> distclean-target, but I'm not sure wether QMake generates such a target.
>
> Andreas
>
Yes that#s true. As I thought before it's not my day ... !
make distclean is generated by qmake and removes the Makefile which indeed
should not be deleted by "make clean".
Eckhard
--
[ signature omitted ]
Message 6 in thread
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Had the same problem just yesterday, no idea why.
After doing a
make clean
make
the problem was solved.
May be it will solve your problem too.
Guenther
Eckhard Jokisch wrote:
> Hi all,
> my attempts to subclass a ui drive me crazy. I'm sure I just don't see the
> point. Can someone help me out?
> BR
> Eckhard
>
> I have a widget defined as requirement.ui
> uic produces ui_requirement.h as expected having:
> ------
> namespace Ui {
> class Requirement: public Ui_Requirement {};
> } // namespace Ui
> --------
>
> in the end.
> now I have requirement.h as:
>
> --------
> #include "ui_requirement.h"
>
> class Req : public QWidget, private Ui::Requirement
> {
> Q_OBJECT
>
> public:
> Req(QWidget *parent =0);
> };
> --------
> and requirement.cpp as:
>
> --------
>
> #include "requirement.h"
>
> Req::Req(QWidget *parent)
> : QWidget(parent)
> {
> setupUi(this);
> }
> --------
> giving the linker error:
> ----------
> requirement.cpp: undefined refernece to vtable for Req
>
> --
> 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/
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHbkbYBHmv7LX78tMRAlydAJ0TNEX4PNj+tUw4mg656ELbpHS1wwCePleo
ILOCYJblRkk1mxTPJdFLB60=
=xQ2K
-----END PGP SIGNATURE-----
--
[ signature omitted ]
Message 7 in thread
Hi,
I'm not sure if it helps, but I sub-class _publicly_ from the UI::classname
and don't get a linker error. And perhaps you also need to sub-class from a
QDialog, not a QWidget?!
My sample code that works:
about.h:
#include "ui_about.h"
class About : public QDialog, public Ui::About
{
Q_OBJECT
public:
About(QWidget *parent = 0);
~About();
public slots:
protected:
};
about.cpp:
#include "about.h"
About::About(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
...
}
About::~About()
{
...
}
HTH, René
On Sun December 23 2007 12:16, Eckhard Jokisch wrote:
> Hi all,
> my attempts to subclass a ui drive me crazy. I'm sure I just don't see the
> point. Can someone help me out?
> BR
> Eckhard
>
> I have a widget defined as requirement.ui
> uic produces ui_requirement.h as expected having:
> ------
> namespace Ui {
> class Requirement: public Ui_Requirement {};
> } // namespace Ui
> --------
>
> in the end.
> now I have requirement.h as:
>
> --------
> #include "ui_requirement.h"
>
> class Req : public QWidget, private Ui::Requirement
> {
> Q_OBJECT
>
> public:
> Req(QWidget *parent =0);
> };
> --------
> and requirement.cpp as:
>
> --------
>
> #include "requirement.h"
>
> Req::Req(QWidget *parent)
>
> : QWidget(parent)
>
> {
> setupUi(this);
> }
> --------
> giving the linker error:
> ----------
> requirement.cpp: undefined refernece to vtable for Req
>
> --
> 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 ]