g++ -I... -L... -lqt ...
Output:
**********************************************************************************************
Keyboard.cpp: In constructor `Keyboard::Keyboard(QWidget*, const char*)':
Keyboard.cpp:7: error: initializer list being treated as compound expression
Keyboard.cpp:7: error: cannot convert `Keyboard* const' to `Qt::Key' in
initialization
main_Keyboard.cpp: In function `int main(int, char**)':
main_Keyboard.cpp:8: error: statement cannot resolve address of overloaded
function
***********************************************************************************************
Wieso erkennt der g++ Key als Unterklasse von Qt::
Warum kann er die Adresse nicht auflösen?
Input:
###########main.cpp #################
#include <qapplication.h>
#include "Keyboard.h"
int main(int argc, char ** argv)
{
QApplication a(argc, argv);
Keyboard *kb = new Keyboard();
kb->show;
return a.exec();
}
################# key.h ####################
#ifndef KEY_H
#define KEY_H
#include <qpushbutton.h>
class Key : public QPushButton
{
public:
// Key( QWidget * parent, const char * name = 0 );
Key( int val, const QString & text, QWidget * parent, const char * name);
~Key();
private:
int value;
};
#endif //KEY_H
################ key.cpp ##################
#include "Key.h"
#include <qpushbutton.h>
/* Key::Key( QWidget * parent, const char * name = 0 )
: QPushButton(parent, name) ;
*/
Key::Key( int val = 0, const QString & text = 0, QWidget * parent = 0, const char * name = 0 ) : QPushButton(text, parent, name)
{
value = val;
}
Key::~Key()
{
}
################ keyboard.h ################
#ifndef KEYBOARD_H
#define KEYBOARD_H
#include <qwidget.h>
#include "Key.h"
class Keyboard : public QWidget
{
public:
Keyboard( QWidget* parent = 0, const char* name = 0);
~Keyboard();
private:
};
#endif // KEYBOARD_H
################ keyboard.cpp ##############
#include "Keyboard.h"
#include "Key.h"
Keyboard::Keyboard( QWidget* parent, const char* name)
: QWidget(parent, name)
{
Key *k = new Key(13, "Hello World", this);
}
Keyboard::~Keyboard()
{
}
#########################################
cu,
Pumbah