Hi everybody
I have created a widget with the designer. Now i am trying to subclass it like the doc, i get following error by compiling. Can somebody see the problem?
main.cpp
Qt Code:
  1. #include <QApplication>
  2. #include "dialog.h"
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication app(argc, argv);
  7.  
  8. Dialog dialog;
  9. dialog.show();
  10. return app.exec();
  11. }
To copy to clipboard, switch view to plain text mode 

dialog.h
Qt Code:
  1. #include "ui_widget1.h"
  2.  
  3.  
  4. class Dialog : public QDialog
  5. {
  6. Q_OBJECT
  7.  
  8. public:
  9. Dialog(QWidget *parent = 0);
  10.  
  11. private:
  12. Ui::Dialog ui;
  13. };
To copy to clipboard, switch view to plain text mode 

dialog.cpp
Qt Code:
  1. #include "dialog.h"
  2.  
  3. Dialog::Dialog(QWidget *parent)
  4. : QDialog(parent)
  5. {
  6. ui.setupUi(this);
  7.  
  8. }
To copy to clipboard, switch view to plain text mode 

ui_widget1.h
Qt Code:
  1. #ifndef UI_WIDGET1_H
  2. #define UI_WIDGET1_H
  3.  
  4. #include <QtCore/QVariant>
  5. #include <QtGui/QAction>
  6. #include <QtGui/QApplication>
  7. #include <QtGui/QButtonGroup>
  8. #include <QtGui/QPushButton>
  9. #include <QtGui/QWidget>
  10.  
  11. class Ui_Widget1
  12. {
  13. public:
  14. QPushButton *btn1;
  15. QPushButton *btn1_2;
  16.  
  17. void setupUi(QWidget *Widget1)
  18. {
  19. Widget1->setObjectName(QString::fromUtf8("Widget1"));
  20. Widget1->resize(QSize(181, 101).expandedTo(Widget1->minimumSizeHint()));
  21. btn1 = new QPushButton(Widget1);
  22. btn1->setObjectName(QString::fromUtf8("btn1"));
  23. btn1->setGeometry(QRect(50, 40, 75, 24));
  24. btn1_2 = new QPushButton(Widget1);
  25. btn1_2->setObjectName(QString::fromUtf8("btn1_2"));
  26. btn1_2->setGeometry(QRect(100, 70, 75, 24));
  27. retranslateUi(Widget1);
  28.  
  29. QMetaObject::connectSlotsByName(Widget1);
  30. } // setupUi
  31.  
  32. void retranslateUi(QWidget *Widget1)
  33. {
  34. Widget1->setWindowTitle(QApplication::translate("Widget1", "Ich bin ein Widget", 0, QApplication::UnicodeUTF8));
  35. btn1->setText(QApplication::translate("Widget1", "Show Message", 0, QApplication::UnicodeUTF8));
  36. btn1_2->setText(QApplication::translate("Widget1", "Show Message", 0, QApplication::UnicodeUTF8));
  37. Q_UNUSED(Widget1);
  38. } // retranslateUi
  39.  
  40. };
  41.  
  42. namespace Ui {
  43. class Widget1: public Ui_Widget1 {};
  44. } // namespace Ui
  45.  
  46. #endif // UI_WIDGET1_H
To copy to clipboard, switch view to plain text mode 

ERROR:
Qt Code:
  1. dialog.h:5: error: invalid use of undefined type `struct QDialog'
  2. D:/apps/Qt/4.1.3/include/QtGui/../../src/gui/kernel/qwindowdefs.h:38: error: for
  3. ward declaration of `struct QDialog'
  4. dialog.h:12: error: using-declaration for non-member at class scope
  5. dialog.h:12: error: expected `;' before "ui"
  6. In file included from dialog.cpp:1:
  7. dialog.h:13:3: warning: no newline at end of file
  8. dialog.cpp: In constructor `Dialog::Dialog(QWidget*)':
  9. dialog.cpp:4: error: type `struct QDialog' is not a direct base of `Dialog'
  10. dialog.cpp:6: error: `ui' undeclared (first use this function)
  11. dialog.cpp:6: error: (Each undeclared identifier is reported only once for each
  12. function it appears in.)
  13. dialog.cpp:8:2: warning: no newline at end of file
  14. mingw32-make[1]: *** [release\dialog.o] Error 1
  15. mingw32-make[1]: Leaving directory `W:/Data/qt4/einstieg/widget'
  16. mingw32-make: *** [release] Error 2
To copy to clipboard, switch view to plain text mode 

Thank you