PDA

View Full Version : begineer in QT



Community_probs
20th September 2007, 13:39
hi to all
I m trying to create a form and on click on a button that data from QLine Edit should be submitted to the Database . but that is not working .
:o

wysota
20th September 2007, 13:45
Could you provide any details on what you actually did?

Community_probs
20th September 2007, 13:57
I have created 3 files as app.h,app.cpp,main.cpp
to create a form with submit and cancel button .
But after compliling it is showing:--

"app1.h:13: Error: Class contains Q_OBJECT macro but does not inherit from QObje
t"

wysota
20th September 2007, 13:58
So did you make it inherit QObject?

Community_probs
20th September 2007, 14:05
i m writing the code as in:-

#ifndef APP1_H
#define APP1_H

class QPushButton;
class QLineEdit;
class QLabel;
class QGridLayout;
class QWindow;


class app1
{
Q_OBJECT
public:
app1(QWidget *parent=0);


private:
QLabel *cust_id;
QLineEdit *tcust;
QPushButton *sub;
QPushButton *can;
QGridLayout *lay2;
QWidget *window;

};
#endif

wysota
20th September 2007, 14:11
But why did you use Q_OBJECT without inheriting QObject? The compiler told you what is wrong. Either remove the macro or inherit QObject.

Community_probs
20th September 2007, 14:15
but i m refering a book as "c++ GUI Programming with QT -4.1.1"
its is given there and more over.
i have created a form in which there was no problem but now its is giving that Error

wysota
20th September 2007, 16:29
I'm sure the book doesn't tell you to create a class which doesn't inherit QObject and use Q_OBJECT macro with it. You probably wanted:

class app1 : public QWidget {
//...
};