Hello there
I seem to be encountering a linker error from GNU, whereby I'm getting an undefined reference which seems to think I've declared but did not implement a virtual method. In my case, I believe I've implemented all the functions thereafter. The reasoning behind creating this overloaded class is to further define slots to be used to update the QLineEdit relative to the buttons, otherwise if Qapplication isn't inherited another slot we'll get the following error when loading onto the board.
Object::connect: No such slot QApplication::setValue_1()
Object::connect: (receiver name: '2nd')
I believe the issue is strongly tied to my constructor and have tried writing the following constructor to alleviate the vtable problem (seen below):
MyClass::MyClass(int & argc, char ** argv) : QApplication(argc,argv) {}
I would really appreciate anybody out there that could help.
-Jeff
jefflong@vlsi42:~/qt_sandbox/2nd$ make
arm-linux-g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I../../qt-embedded-linux-opensource-src-4.4.0-rc1/mkspecs/qws/linux-arm-g++ -I. -I../../qt-embedded-linux-opensource-src-4.4.0-rc1/include/QtCore -I../../qt-embedded-linux-opensource-src-4.4.0-rc1/include/QtCore -I../../qt-embedded-linux-opensource-src-4.4.0-rc1/include/QtNetwork -I../../qt-embedded-linux-opensource-src-4.4.0-rc1/include/QtNetwork -I../../qt-embedded-linux-opensource-src-4.4.0-rc1/include/QtGui -I../../qt-embedded-linux-opensource-src-4.4.0-rc1/include/QtGui -I../../qt-embedded-linux-opensource-src-4.4.0-rc1/include -I. -I. -I. -o main.o main.cpp
arm-linux-g++ -Wl,-rpath,/usr/lib/qt-4.4.0/lib -o 2nd main.o -L/usr/lib/qt-4.4.0/lib -lQtGui -L/home/jefflong/qt-embedded-linux-opensource-src-4.4.0-rc1/lib -lts -lQtNetwork -lQtCore -lz -lm -lrt -ldl -lpthread
main.o: In function `main':
main.cpp

.text+0x57c): undefined reference to `vtable for MyClass'
collect2: ld returned 1 exit status
make: *** [2nd] Error 1
//start of code
#include <QApplication>
#include <QPushButton>
#include <QWidget>
#include <QString>
#include <QIcon>
#include <QLineEdit>
#include <QtGui>
#include <QLCDNumber>
#include <QAction>
#include <QToolBar>
#include <QMainWindow>
#define BUTTON_X_MIN 0
#define BUTTON_Y_MIN 0
#define BUTTON_HEIGHT 60
#define BUTTON_WIDTH 60
#define WINDOW_HEIGHT 300
#define WINDOW_WIDTH 600
#define NUMBER_ICONS 12
const QString rsrcPath = ":/images";
char keys[] = {'1','2','3','4','5','6','7','8','9','*','0','#'};
QString temp,LCD_Feed = "hello";
int LCD_Count = 0;
class MyClass : public QApplication
{
Q_OBJECT
public:
MyClass(int & argc, char ** argv) : QApplication(argc,argv) { }
public slots:
void setValue_1();
};
int main(int argc, char *argv[])
{
// QApplication app(argc, argv);
MyClass app(argc, argv);
QWidget window;
window.resize(WINDOW_WIDTH, WINDOW_HEIGHT);
QIcon * button_icons[NUMBER_ICONS];
QPushButton * buttons[NUMBER_ICONS];
int counter;
char temp[128];
int row = 0;
for(counter=0; counter < NUMBER_ICONS; ++counter)
{
if( counter % 3 == 0 && counter > 0)
++row;
sprintf(temp,"images/number_%c.png",keys[counter]);
button_icons[counter] = new QIcon(temp);
buttons[counter] = new QPushButton(*button_icons[counter],NULL,&window);
buttons[counter]->setGeometry(BUTTON_X_MIN + (counter % 3) * BUTTON_WIDTH,BUTTON_Y_MIN+row*BUTTON_HEIGHT,BUTTON_WIDTH,BUTTON_HEIGHT);
// QObject:: connect(buttons[counter], SIGNAL(clicked()), &app, SLOT(quit()));
}
QObject::connect(buttons[1], SIGNAL(clicked()), &app, SLOT(setValue_1()));
// QObject::connect(buttons[2], SIGNAL(clicked()), &app, SLOT(quit()));
// QObject::connect(buttons[3], SIGNAL(clicked()), &app, SLOT(quit()));
// QObject::connect(buttons[4], SIGNAL(clicked()), &app, SLOT(quit()));
// QObject::connect(buttons[5], SIGNAL(clicked()), &app, SLOT(quit()));
// QObject::connect(buttons[6], SIGNAL(clicked()), &app, SLOT(quit()));
// QObject::connect(buttons[7], SIGNAL(clicked()), &app, SLOT(quit()));
// QObject::connect(buttons[8], SIGNAL(clicked()), &app, SLOT(quit()));
// QObject::connect(buttons[9], SIGNAL(clicked()), &app, SLOT(quit()));
// QObject::connect(buttons[10], SIGNAL(clicked()), &app, SLOT(quit()));
// QObject::connect(buttons[11], SIGNAL(clicked()), &app, SLOT(quit()));
// QObject::connect(buttons[12], SIGNAL(triggered()), &app, SLOT(quit()));
QLineEdit *theLCD;
theLCD = new QLineEdit(LCD_Feed,&window);
theLCD->setGeometry(200,150,80,40);
theLCD->setAlignment(Qt::AlignHCenter);
//echoLineEdit->setEchoMode(QLineEdit::phone_number);//is this placed here or elsewhere
window.show();
return app.exec();
}
void MyClass::setValue_1()
{
temp = "1";
// setValue(temp);
switch(LCD_Count){
case 0:
LCD_Feed.append("

"

;
LCD_Feed.append(temp);
LCD_Count = 2;
break;
case 3:
LCD_Feed.append(temp);
LCD_Feed.append("

"

;
LCD_Count = 6;
break;
case 8:
LCD_Feed.append("-"

;
LCD_Feed.append(temp);
LCD_Count = 10;
break;
case 14:
LCD_Feed = " ";
LCD_Count = 0;
break;
default:
LCD_Feed.append(temp);
LCD_Count++;
break;
}
}