Results 1 to 2 of 2

Thread: Error on constructor

  1. #1
    Join Date
    Jul 2015
    Location
    Austria
    Posts
    20
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Question Error on constructor

    Hi everyone,
    i always get this error when i compile :
    'Viewer' has not been declared

    My viewer.h and modultreewidget.h are in the same directory.

    MODULTREEWIDGET:
    Qt Code:
    1. #ifndef MODULTREEWIDGET_H
    2. #define MODULTREEWIDGET_H
    3.  
    4. #include <QWidget>
    5. #include <QTreeWidget>
    6. #include <QTimer>
    7. #include "viewer.h"
    8. #include "basewidget.h"
    9.  
    10. class ModulTreeWidget : public QTreeWidget
    11. {
    12. Q_OBJECT
    13. public:
    14. explicit ModulTreeWidget(QTreeWidget *parent=0,Viewer *v=0);
    15. ~ModulTreeWidget();
    16. void addModule(BaseWidget *b);
    17. public slots:
    18. void startPresentation();
    19. void showNext();
    20. private:
    21. std::vector<BaseWidget*> baseWidgets;
    22. int count;
    23. int currentId;
    24. };
    25.  
    26. #endif // MODULTREEWIDGET_H
    To copy to clipboard, switch view to plain text mode 

    VIEWER:
    Qt Code:
    1. #ifndef VIEWER_H
    2. #define VIEWER_H
    3.  
    4. #include <QMainWindow>
    5. #include <QWidget>
    6. #include <QVBoxLayout>
    7. #include <QLabel>
    8. #include <QDebug>
    9. #include <QStringList>
    10. #include <QInputDialog>
    11. #include <QString>
    12. #include <QMessageBox>
    13. #include <QVector>
    14. #include <QListWidget>
    15. #include <QListWidgetItem>
    16. #include <QTableWidgetItem>
    17. #include <QList>
    18. #include <QItemSelectionModel>
    19. #include <QModelIndexList>
    20. #include "basewidget.h"
    21. #include "tabledialog.h"
    22. #include <QTreeWidget>
    23. #include <QTreeWidgetItem>
    24. #include <vector>
    25. #include <QDesktopWidget>
    26. #include <QColorDialog>
    27. #include "modultreewidget.h"
    28.  
    29. namespace Ui {
    30. class Viewer;
    31. }
    32.  
    33. class Viewer : public QMainWindow
    34. {
    35. Q_OBJECT
    36.  
    37. public:
    38. explicit Viewer(QWidget *parent = 0);
    39. ~Viewer();
    To copy to clipboard, switch view to plain text mode 
    What´s the problem?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Error on constructor

    Try to reduce the includes inside headers by forward declaring classes that are only needed as pointers.

    For example in modultreewidget.h you only need QTreeWidget.

    Right now you have a circular dependency of viewer.h and modultreewidget.h

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    mayrhofer (29th December 2015)

Similar Threads

  1. Constructor Error, please assist
    By ayanda83 in forum Newbie
    Replies: 1
    Last Post: 13th March 2014, 15:42
  2. Replies: 1
    Last Post: 30th December 2013, 14:53
  3. what does the constructor do here?
    By LB4229 in forum Qt Programming
    Replies: 7
    Last Post: 22nd June 2011, 03:19
  4. Replies: 4
    Last Post: 9th September 2009, 09:02
  5. error with constructor or OnInit
    By chochatown in forum Qt Programming
    Replies: 3
    Last Post: 30th May 2009, 22:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.