Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. not finding class
Forum Updated to NodeBB v4.3 + New Features

not finding class

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 3 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    saber
    wrote on last edited by
    #1

    i included the header file .but it is telling me it can't find the class

    /home/shaber/Desktop/Folder/work3/coreApps/app/corepad/corepad.h:85: error: ‘coreedit’ does not name a type; did you mean ‘corepad’?
         coreedit *text;
         ^~~~~~~~
         corepad
    

    0_1534146349521_Screenshot_2018-08-13_13-44-06.png

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      if you are VERY sure, that
      you spelled classname right and have the right include file, the right place.
      Then maybe you included corepad in corededit and reverse ?

      S 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        if you are VERY sure, that
        you spelled classname right and have the right include file, the right place.
        Then maybe you included corepad in corededit and reverse ?

        S Offline
        S Offline
        saber
        wrote on last edited by saber
        #3

        @mrjj
        i am pretty sure of spelling and include .
        when i do ctrl + mouseclike on the include and the declaration ,it drictly goes to the coreedit.h

        mrjjM 1 Reply Last reply
        0
        • S saber

          @mrjj
          i am pretty sure of spelling and include .
          when i do ctrl + mouseclike on the include and the declaration ,it drictly goes to the coreedit.h

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @saber

          ok make sure its not a circular reference then.
          also, clean build folder completely and rerun qmake and
          see.

          S 1 Reply Last reply
          0
          • mrjjM mrjj

            @saber

            ok make sure its not a circular reference then.
            also, clean build folder completely and rerun qmake and
            see.

            S Offline
            S Offline
            saber
            wrote on last edited by
            #5

            @mrjj
            i am clean building it.
            and what is circular reference?can you see the picture and see if i did?

            mrjjM 1 Reply Last reply
            0
            • S saber

              @mrjj
              i am clean building it.
              and what is circular reference?can you see the picture and see if i did?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @saber
              hi
              it means file1 include file2 and file2 includes file1 ( in .h)

              S 1 Reply Last reply
              1
              • mrjjM mrjj

                @saber
                hi
                it means file1 include file2 and file2 includes file1 ( in .h)

                S Offline
                S Offline
                saber
                wrote on last edited by saber
                #7

                @mrjj
                clean buil not worked and i did not circular reference.

                update : i think reference is hepping through another cpp file. that cpp used by both

                mrjjM jsulmJ 2 Replies Last reply
                0
                • S saber

                  @mrjj
                  clean buil not worked and i did not circular reference.

                  update : i think reference is hepping through another cpp file. that cpp used by both

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @saber
                  if inside .cpp
                  like
                  include A.h
                  include B.h
                  then its pretty normal.
                  and its not that.

                  Try a clean file.
                  and try use the class i dont know and see if same thing happens.

                  1 Reply Last reply
                  0
                  • S saber

                    @mrjj
                    clean buil not worked and i did not circular reference.

                    update : i think reference is hepping through another cpp file. that cpp used by both

                    jsulmJ Online
                    jsulmJ Online
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @saber Can you show coreedit.h and corepad.h? But please not as screen-shot!
                    Is coreedit in a namespace?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    S 1 Reply Last reply
                    2
                    • jsulmJ jsulm

                      @saber Can you show coreedit.h and corepad.h? But please not as screen-shot!
                      Is coreedit in a namespace?

                      S Offline
                      S Offline
                      saber
                      wrote on last edited by
                      #10

                      @jsulm

                      
                      #ifndef COREEDIT_H
                      #define COREEDIT_H
                      
                      #include "chighlighter.h"
                      
                      #include <QDebug>
                      #include <QPlainTextEdit>
                      #include <QPainter>
                      #include <QTextBlock>
                      
                      //#include "utilities/utilities.h"
                      
                      
                      class coreedit : public QPlainTextEdit
                      {
                          Q_OBJECT
                      
                      public:
                          coreedit(QString fPath, QWidget *parent = 0);
                      
                          QString workFilePath() const {
                              return filePath;}
                      
                          void lineNumberAreaPaintEvent(QPaintEvent *event);
                          int lineNumberAreaWidth();
                      
                          QWidget* lineNumberArea_() const {
                              return lineNumberArea;}
                      
                      protected:
                          void resizeEvent(QResizeEvent *event) override;
                      
                      private slots:
                          void updateLineNumberAreaWidth(int newBlockCount);
                          void highlightCurrentLine();
                          void updateLineNumberArea(const QRect &, int);
                      
                      private:
                          QString filePath;
                          QWidget *lineNumberArea;
                      
                      };
                      
                      
                      class LineNumberArea : public QWidget
                      {
                      public:
                          LineNumberArea(coreedit *editor) : QWidget(editor) {
                              coreedit_ = editor;}
                      
                          QSize sizeHint() const override {
                              return QSize(coreedit_->lineNumberAreaWidth(), 0);}
                      
                      protected:
                          void paintEvent(QPaintEvent *event) override {
                              coreedit_->lineNumberAreaPaintEvent(event);}
                      
                      private:
                          coreedit *coreedit_;
                      
                      };
                      
                      #endif // COREEDIT_H
                      
                      
                      
                      #ifndef COREPAD_H
                      #define COREPAD_H
                      
                      #include <QFile>
                      #include <QFileDialog>
                      #include <QShortcut>
                      #include <QFileInfo>
                      #include <QDate>
                      #include <QDateTime>
                      #include <QMessageBox>
                      #include <QDebug>
                      #include <QWidget>
                      #include <QCloseEvent>
                      
                      #include "utilities/utilities.h"
                      #include "bookmarks/bookmarks.h"
                      #include "coreedit.h"
                      
                      
                      namespace Ui {
                      class corepad;
                      }
                      
                      class corepad : public QWidget
                      {
                          Q_OBJECT
                      
                      public:
                          explicit corepad(QWidget *parent = 0);
                          ~corepad();
                      
                          QString workFilePath;
                          void openText(const QString &filePath);
                          bool initializeNewTab(const QString &filePath);
                          int tabsCount();
                          QString currentFilePath(int index);
                      
                      private slots:
                          void textCopyAvailable(bool b);
                          void textUndoAvailable(bool b);
                          void textRedoAvailable(bool b);
                          void textTextChanged();
                          void on_notes_currentChanged(int index);
                          void on_notes_tabCloseRequested(int index);
                          void on_cOpen_clicked();
                          void on_cNew_clicked();
                          bool on_cSave_clicked();
                          void on_cSaveAs_clicked();
                          void on_cCopy_clicked();
                          void on_cPaste_clicked();
                          void on_cCut_clicked();
                          void on_cUndo_clicked();
                          void on_cRedo_clicked();
                          void on_addDate_clicked();
                          void on_bookMarkIt_clicked();
                          void on_searchHere_textChanged(const QString &arg1);
                          void on_nextW_clicked();
                          void on_previousW_clicked();
                          void quitClicked();
                          void on_fontShow_clicked();
                          void on_fontSize_valueChanged(int arg1);
                          void on_search_clicked();
                      
                      protected:
                          void closeEvent(QCloseEvent *event);
                      
                      private:
                          Ui::corepad *ui;
                          coreedit *text;
                          QStringList tabInfo; //Store tab information (Index, IsSaved, IsUpdated, FilePath)
                      
                          bool started;
                          bool saveTo(const QString &filePath);
                          void findS(QString searchS, bool reverse, QTextDocument::FindFlags flag = nullptr);
                          bool closeTab(int index);
                      
                          //Accessing information through tab information
                          QString isCurrentSaved(int index);
                          QString isCurrentUpdated(int index);
                      
                          //Saving information at tab information
                          bool setCurrent(int index, int isSaved, int isUpdated, const QString &filePath);
                      
                          void shotcuts();
                          void reIndex();
                      };
                      
                      #endif // COREPAD_H
                      
                      
                      jsulmJ 1 Reply Last reply
                      0
                      • S saber

                        @jsulm

                        
                        #ifndef COREEDIT_H
                        #define COREEDIT_H
                        
                        #include "chighlighter.h"
                        
                        #include <QDebug>
                        #include <QPlainTextEdit>
                        #include <QPainter>
                        #include <QTextBlock>
                        
                        //#include "utilities/utilities.h"
                        
                        
                        class coreedit : public QPlainTextEdit
                        {
                            Q_OBJECT
                        
                        public:
                            coreedit(QString fPath, QWidget *parent = 0);
                        
                            QString workFilePath() const {
                                return filePath;}
                        
                            void lineNumberAreaPaintEvent(QPaintEvent *event);
                            int lineNumberAreaWidth();
                        
                            QWidget* lineNumberArea_() const {
                                return lineNumberArea;}
                        
                        protected:
                            void resizeEvent(QResizeEvent *event) override;
                        
                        private slots:
                            void updateLineNumberAreaWidth(int newBlockCount);
                            void highlightCurrentLine();
                            void updateLineNumberArea(const QRect &, int);
                        
                        private:
                            QString filePath;
                            QWidget *lineNumberArea;
                        
                        };
                        
                        
                        class LineNumberArea : public QWidget
                        {
                        public:
                            LineNumberArea(coreedit *editor) : QWidget(editor) {
                                coreedit_ = editor;}
                        
                            QSize sizeHint() const override {
                                return QSize(coreedit_->lineNumberAreaWidth(), 0);}
                        
                        protected:
                            void paintEvent(QPaintEvent *event) override {
                                coreedit_->lineNumberAreaPaintEvent(event);}
                        
                        private:
                            coreedit *coreedit_;
                        
                        };
                        
                        #endif // COREEDIT_H
                        
                        
                        
                        #ifndef COREPAD_H
                        #define COREPAD_H
                        
                        #include <QFile>
                        #include <QFileDialog>
                        #include <QShortcut>
                        #include <QFileInfo>
                        #include <QDate>
                        #include <QDateTime>
                        #include <QMessageBox>
                        #include <QDebug>
                        #include <QWidget>
                        #include <QCloseEvent>
                        
                        #include "utilities/utilities.h"
                        #include "bookmarks/bookmarks.h"
                        #include "coreedit.h"
                        
                        
                        namespace Ui {
                        class corepad;
                        }
                        
                        class corepad : public QWidget
                        {
                            Q_OBJECT
                        
                        public:
                            explicit corepad(QWidget *parent = 0);
                            ~corepad();
                        
                            QString workFilePath;
                            void openText(const QString &filePath);
                            bool initializeNewTab(const QString &filePath);
                            int tabsCount();
                            QString currentFilePath(int index);
                        
                        private slots:
                            void textCopyAvailable(bool b);
                            void textUndoAvailable(bool b);
                            void textRedoAvailable(bool b);
                            void textTextChanged();
                            void on_notes_currentChanged(int index);
                            void on_notes_tabCloseRequested(int index);
                            void on_cOpen_clicked();
                            void on_cNew_clicked();
                            bool on_cSave_clicked();
                            void on_cSaveAs_clicked();
                            void on_cCopy_clicked();
                            void on_cPaste_clicked();
                            void on_cCut_clicked();
                            void on_cUndo_clicked();
                            void on_cRedo_clicked();
                            void on_addDate_clicked();
                            void on_bookMarkIt_clicked();
                            void on_searchHere_textChanged(const QString &arg1);
                            void on_nextW_clicked();
                            void on_previousW_clicked();
                            void quitClicked();
                            void on_fontShow_clicked();
                            void on_fontSize_valueChanged(int arg1);
                            void on_search_clicked();
                        
                        protected:
                            void closeEvent(QCloseEvent *event);
                        
                        private:
                            Ui::corepad *ui;
                            coreedit *text;
                            QStringList tabInfo; //Store tab information (Index, IsSaved, IsUpdated, FilePath)
                        
                            bool started;
                            bool saveTo(const QString &filePath);
                            void findS(QString searchS, bool reverse, QTextDocument::FindFlags flag = nullptr);
                            bool closeTab(int index);
                        
                            //Accessing information through tab information
                            QString isCurrentSaved(int index);
                            QString isCurrentUpdated(int index);
                        
                            //Saving information at tab information
                            bool setCurrent(int index, int isSaved, int isUpdated, const QString &filePath);
                        
                            void shotcuts();
                            void reIndex();
                        };
                        
                        #endif // COREPAD_H
                        
                        
                        jsulmJ Online
                        jsulmJ Online
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by jsulm
                        #11

                        @saber Since you're only using a pointer to coreedit it would be enough to have a forward declaration. So, instead of including coreedit.h (remove it) you can do:

                        class coreeedit;
                        class corepad: ...
                        

                        And include coreedit.h in corepad.cpp.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          saber
                          wrote on last edited by saber
                          #12

                          i first commented the third.cpp from the coreedite.h then it builds fine.
                          and reverse the way it dose not build .

                          so the circular reference is happing through another cpp file.
                          here it is #include "utilities/utilities.h" ,see it is included in both header file.

                          what can i do?

                          jsulmJ 1 Reply Last reply
                          0
                          • S saber

                            i first commented the third.cpp from the coreedite.h then it builds fine.
                            and reverse the way it dose not build .

                            so the circular reference is happing through another cpp file.
                            here it is #include "utilities/utilities.h" ,see it is included in both header file.

                            what can i do?

                            jsulmJ Online
                            jsulmJ Online
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by jsulm
                            #13

                            @saber Get rid of circular dependency. How? Read my post above about forward declarations. And think about your design: does a utility class really need to know about coreedit?

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            S 1 Reply Last reply
                            2
                            • jsulmJ jsulm

                              @saber Get rid of circular dependency. How? Read my post above about forward declarations. And think about your design: does a utility class really need to know about coreedit?

                              S Offline
                              S Offline
                              saber
                              wrote on last edited by
                              #14

                              @jsulm
                              i can confirm that the cause is circular dependency.
                              i restructured my cpp files and function .sperated the function that used by every cpp file .
                              now it fixed.
                              sorry i did not understand the forward declaration.but i will try to understand .

                              jsulmJ 1 Reply Last reply
                              0
                              • S saber

                                @jsulm
                                i can confirm that the cause is circular dependency.
                                i restructured my cpp files and function .sperated the function that used by every cpp file .
                                now it fixed.
                                sorry i did not understand the forward declaration.but i will try to understand .

                                jsulmJ Online
                                jsulmJ Online
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @saber Forward declaration is just a declaration of a class without definition (without class body):

                                class coreeedit; // This is forward declaration
                                class corepad: ...
                                

                                Farward declaration in this case tells the compiler that coreedit is a class, this is already enough information for compiler to declare pointers to coreedit. But in cpp you need to include the header file with coreedit definition, so compiler knows more about it to be able to access its variables and methods.

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                S 1 Reply Last reply
                                3
                                • jsulmJ jsulm

                                  @saber Forward declaration is just a declaration of a class without definition (without class body):

                                  class coreeedit; // This is forward declaration
                                  class corepad: ...
                                  

                                  Farward declaration in this case tells the compiler that coreedit is a class, this is already enough information for compiler to declare pointers to coreedit. But in cpp you need to include the header file with coreedit definition, so compiler knows more about it to be able to access its variables and methods.

                                  S Offline
                                  S Offline
                                  saber
                                  wrote on last edited by
                                  #16

                                  @jsulm ohh .understand .
                                  i saw those in many cpp files.i understand now those.
                                  thanks

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved