Help! is there errors in codes copied from book ?
-
I'm a total greenhand on qt,and I lent some books form library. I copied the "helloworld" code from the book to my QTcreator, and it ran perfectly. But when I started to build some more conplex code copied from the book, it start to make errors.
this is the code:
@
//addressbook.h#ifndef ADDRESSBOOK_H
#define ADDRESSBOOK_H#include <QWidget>
class QLineEdit;
class AddressBook : public QWidget
{
Q_OBJECT
public:
AddressBook(QWidget *parent = 0);
private:
QLineEditor * nameline;
QTextEditor * addresstext;
};#endif // ADDRESSBOOK_H
@
It said the "QLineEditor" (and lots of other things) need declaeration in the scope. Is there missing some lib or header?Edit: please use @ tags around code sections; Andre
-
[quote author="Lukas Geyer" date="1322203500"]
As long as you just use pointers a forward declaration is sufficient. There is no need to include headers.[/quote]In fact, in most cases it's good practice to not include the header where a forward declaration is sufficient. Speeding up compile time is only one of the advantages.
-
[quote author="Lukas Geyer" date="1322203450"]It is spelled QLineEdit, not QLineEditor. In addition, you are missing a forward declaration for QTextEdit in your .h file.[/quote]
I think that's the point. the reason i include qlineedit is it said something is not decleared. there is no include qlineedit on the book.