Linking problems boundary="==_Exmh_13452812500" boundary="==_Exmh_13601327980"
This is a multipart MIME message.
--==_Exmh_13601327980
Content-Type: text/plain; charset=us-ascii
I have the following errors when trying to compile and link a class that
derives from QListBox:
g++ -g -o try try.cc try1.cc -I/usr/include/X11/qt -L/usr/X11R6/lib -lqt
-lg++
/tmp/cca197912.o: In function `ListBox::ListBox(QWidget *, char const *,
unsigned int)':
/usr/home/olly/cprogs/priory_db/try1.cc:44: undefined reference to
`ListBox::QPaintDevice virtual table'
/usr/home/olly/cprogs/priory_db/try1.cc:44: undefined reference to `ListBox
virtual table'
I attach a minimal set of files which demonstrate the bug.
I don't know if this is in fact a bug in the GNU compiler or in QT.
Version levels:
Debian Linux 1.2
GCC 2.7.2.1
libg++ 2.7.2
QT 1.0
Oliver Elphick olly@lfix.co.uk
Isle of Wight http://homepages.enterprise.net/olly
--==_Exmh_13601327980
Content-Type: application/octet-stream
Content-Description: try.cc
Content-Transfer-Encoding: quoted-printable
/* Test program */
#include <qapp.h> // Every program needs one!
#include <qwidget.h>
#include "listitem.h" // Main window's header file
int main (int argc, char **argv)
{
QApplication a(argc, argv);
=
QWidget mw;
a.setMainWidget(&mw);
ListItem *li =3D new ListItem;
mw.show();
=
return a.exec();
}
--==_Exmh_13601327980
Content-Type: text/plain; charset=us-ascii
Content-Description: try1.h
Content-Transfer-Encoding: quoted-printable
/************************************************************************=
*****
Priory database
listitem.h Header file for listitem, one of the four data windows
*************************************************************************=
****/
#ifndef LISTITEM_H
#define LISTITEM_H
#include <qgrpbox.h>
#include <qlistbox.h>
#include <qlabel.h>
#include <String.h>
#include <qlist.h>
class QLabel;
class ListItem : public QListBoxText
{
Q_OBJECT
public:
ListItem(const char *k=3D0, const char *t=3D0);
void setKey(const char *);
void setValues(const char *, const char *);
const char *key() const;
protected:
void resizeEvent(QResizeEvent *);
private:
String *ky;
};
//////////
class ListBox : public QListBox
{
Q_OBJECT
public:
ListBox(QWidget *parent=3D0, const char *name=3D0, WFlags f=3D0);
const char * key(int);
const char * currentKey();
void removeItem(int);
void insertItem(const ListItem * li, int i=3D-1);
void clear();
private:
QList<const char *> *kix;
};
#endif LISTITEM_H
--==_Exmh_13601327980
Content-Type: application/octet-stream
Content-Description: try1.cc
Content-Transfer-Encoding: quoted-printable
/************************************************************************=
*****
Priory database
listitem.cc Class file for listitem, which groups two labels
together for use in a list box; one label is for use as a hidden
key to some other table
*************************************************************************=
****/
#include <qapp.h>
#include <qlabel.h>
#include "try1.h"
ListItem::ListItem(const char *k=3D0, const char *t=3D0)
: QListBoxText(t)
{
cerr << "ListItem::ListItem\n";
ky =3D new String(k);
}
void ListItem::setKey(const char *k)
{
delete ky;
ky =3D new String(k); =
}
const char * ListItem::key() const
{
return (const char *) ky;
}
void ListItem::setValues(const char *k, const char *t)
{
setText(t);
setKey(k);
}
////////////
ListBox::ListBox(QWidget *parent, const char *name, WFlags f)
: QListBox(parent, name, f)
{
kix =3D new QList<const char *>();
}
const char * ListBox::key(int i)
{
return *(kix->at(i));
}
const char * ListBox::currentKey()
{
return key(currentItem());
}
void ListBox::insertItem(const ListItem *it, int ix)
{
QListBox::insertItem(
it->text(),
ix);
if (ix >=3D 0)
{
kix->insert((unsigned int) ix, (const char * const *)it->key());
}
else
{
kix->append((const char * const *)it->key());
}
}
void ListBox::clear()
{
QListBox::clear();
kix->clear();
}
void ListBox::removeItem(int ix)
{
QListBox::removeItem(ix);
(void) kix->remove(ix);
}
--==_Exmh_13601327980--
Reply to: