Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to add new class ?

how to add new class ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++designhelptutorialquestion
12 Posts 4 Posters 34 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.
  • L Lost User

    I am seriously trying to learn more about C++_. I did add a new class to the constructor, just following an examples , and I do not understand why I am getting this error. My own add is duplicate of existing , working class, and I do no see why it does no like the pointer.

         m\_serial(new QSerialPort(this),
           // sequence 1\` st add HERE
            m\_TAB\_Ext(new A\_BT\_TAB\_DIALOG\_EXT)
    

    /mnt/A_BT_DEC10/A_APR13_APR15/A_APR9_MAR7_MAR19_CLEAN/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:3088: error: called object type 'A_BT_TAB_DIALOG_EXT *' is not a function or function pointer
    mainwindow_Bluetooth_copy.cpp:3088:22: error: called object type 'A_BT_TAB_DIALOG_EXT *' is not a function or function pointer
    m_TAB_Ext(new A_BT_TAB_DIALOG_EXT())
    ~~~~~~~~~^

    here is my class declaration

    namespace Ui {
    class A_BT_TAB_DIALOG_EXT;
    // add forward declarations ??
    class QMdiArea;
    }

    class A_BT_TAB_DIALOG_EXT : public QWidget
    {
    Q_OBJECT

    public:
    explicit A_BT_TAB_DIALOG_EXT(QWidget *parent = nullptr);
    ~A_BT_TAB_DIALOG_EXT();

    private:
    Ui::A_BT_TAB_DIALOG_EXT *ui;

    // 3 define / declare members / parameters
    
    QLabel \*m\_status = nullptr;
    QMdiArea \*m\_mdiarea = nullptr;
    QSerialPort \*m\_serial = nullptr;
    

    };

    Mircea NeacsuM Offline
    Mircea NeacsuM Offline
    Mircea Neacsu
    wrote on last edited by
    #2

    There is a slight discrepancy in your code. You wrote:

    m_serial(new QSerialPort(this),
    // sequence 1` st add HERE
    m_TAB_Ext(new A_BT_TAB_DIALOG_EXT)

    Meanwhile the compiler error message is:

    m_TAB_Ext(new A_BT_TAB_DIALOG_EXT())

    (note the extra pair of parenthesis). The code you posted is potentially correct, assuming m_TAB_Ext is declared as:

    A_BT_TAB_DIALOG_EXT *m_TAB_Ext;

    However the compiler error message seems to indicate that you have those extra parenthesis and, in this case, the compiler interprets it as a function call.

    Mircea

    L 1 Reply Last reply
    0
    • Mircea NeacsuM Mircea Neacsu

      There is a slight discrepancy in your code. You wrote:

      m_serial(new QSerialPort(this),
      // sequence 1` st add HERE
      m_TAB_Ext(new A_BT_TAB_DIALOG_EXT)

      Meanwhile the compiler error message is:

      m_TAB_Ext(new A_BT_TAB_DIALOG_EXT())

      (note the extra pair of parenthesis). The code you posted is potentially correct, assuming m_TAB_Ext is declared as:

      A_BT_TAB_DIALOG_EXT *m_TAB_Ext;

      However the compiler error message seems to indicate that you have those extra parenthesis and, in this case, the compiler interprets it as a function call.

      Mircea

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #3

      Good catch, but even after removing the () I get same error.

        //! \[1\]
              //! add rfcomm ??
              m\_serial(new QSerialPort(this),
             // sequence 1\` st add HERE
              m\_TAB\_Ext(new A\_BT\_TAB\_DIALOG\_EXT)
      
      Mircea NeacsuM 2 Replies Last reply
      0
      • L Lost User

        Good catch, but even after removing the () I get same error.

          //! \[1\]
                //! add rfcomm ??
                m\_serial(new QSerialPort(this),
               // sequence 1\` st add HERE
                m\_TAB\_Ext(new A\_BT\_TAB\_DIALOG\_EXT)
        
        Mircea NeacsuM Offline
        Mircea NeacsuM Offline
        Mircea Neacsu
        wrote on last edited by
        #4

        I think you are missing the declaration for m_tab_ext. Your class should look like:

        class A_BT_TAB_DIALOG_EXT : public QWidget
        {
        Q_OBJECT

        public:
        explicit A_BT_TAB_DIALOG_EXT(QWidget *parent = nullptr);
        ~A_BT_TAB_DIALOG_EXT();

        private:
        Ui::A_BT_TAB_DIALOG_EXT *ui;

        // 3 define / declare members / parameters
        
        QLabel \*m\_status = nullptr;
        QMdiArea \*m\_mdiarea = nullptr;
        QSerialPort \*m\_serial = nullptr;
        
        A\_BT\_TAB\_DIALOG\_EXT \*m\_TAB\_Ext;
        //...blah, blah, more stuff here
        

        }

        Mircea

        1 Reply Last reply
        0
        • L Lost User

          Good catch, but even after removing the () I get same error.

            //! \[1\]
                  //! add rfcomm ??
                  m\_serial(new QSerialPort(this),
                 // sequence 1\` st add HERE
                  m\_TAB\_Ext(new A\_BT\_TAB\_DIALOG\_EXT)
          
          Mircea NeacsuM Offline
          Mircea NeacsuM Offline
          Mircea Neacsu
          wrote on last edited by
          #5

          Not sure I understand what you try to do. Maybe the code samle is a bit too short. Where is the `m_TAB_ext` initialization line? I don;t see a declaration for `m_TAB_ext`.

          Mircea

          1 Reply Last reply
          0
          • L Lost User

            I am seriously trying to learn more about C++_. I did add a new class to the constructor, just following an examples , and I do not understand why I am getting this error. My own add is duplicate of existing , working class, and I do no see why it does no like the pointer.

                 m\_serial(new QSerialPort(this),
                   // sequence 1\` st add HERE
                    m\_TAB\_Ext(new A\_BT\_TAB\_DIALOG\_EXT)
            

            /mnt/A_BT_DEC10/A_APR13_APR15/A_APR9_MAR7_MAR19_CLEAN/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:3088: error: called object type 'A_BT_TAB_DIALOG_EXT *' is not a function or function pointer
            mainwindow_Bluetooth_copy.cpp:3088:22: error: called object type 'A_BT_TAB_DIALOG_EXT *' is not a function or function pointer
            m_TAB_Ext(new A_BT_TAB_DIALOG_EXT())
            ~~~~~~~~~^

            here is my class declaration

            namespace Ui {
            class A_BT_TAB_DIALOG_EXT;
            // add forward declarations ??
            class QMdiArea;
            }

            class A_BT_TAB_DIALOG_EXT : public QWidget
            {
            Q_OBJECT

            public:
            explicit A_BT_TAB_DIALOG_EXT(QWidget *parent = nullptr);
            ~A_BT_TAB_DIALOG_EXT();

            private:
            Ui::A_BT_TAB_DIALOG_EXT *ui;

            // 3 define / declare members / parameters
            
            QLabel \*m\_status = nullptr;
            QMdiArea \*m\_mdiarea = nullptr;
            QSerialPort \*m\_serial = nullptr;
            

            };

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #6

            Quote:

            m_serial(new QSerialPort(this), // sequence 1` st add HERE m_TAB_Ext(new A_BT_TAB_DIALOG_EXT)

            Which of the overloaded constructors of the QSerialPort class are you trying to call? Could you please show full details of m_TAB_Ext variable?

            "In testa che avete, Signor di Ceprano?" -- Rigoletto

            In testa che avete, signor di Ceprano?

            L 1 Reply Last reply
            0
            • L Lost User

              I am seriously trying to learn more about C++_. I did add a new class to the constructor, just following an examples , and I do not understand why I am getting this error. My own add is duplicate of existing , working class, and I do no see why it does no like the pointer.

                   m\_serial(new QSerialPort(this),
                     // sequence 1\` st add HERE
                      m\_TAB\_Ext(new A\_BT\_TAB\_DIALOG\_EXT)
              

              /mnt/A_BT_DEC10/A_APR13_APR15/A_APR9_MAR7_MAR19_CLEAN/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:3088: error: called object type 'A_BT_TAB_DIALOG_EXT *' is not a function or function pointer
              mainwindow_Bluetooth_copy.cpp:3088:22: error: called object type 'A_BT_TAB_DIALOG_EXT *' is not a function or function pointer
              m_TAB_Ext(new A_BT_TAB_DIALOG_EXT())
              ~~~~~~~~~^

              here is my class declaration

              namespace Ui {
              class A_BT_TAB_DIALOG_EXT;
              // add forward declarations ??
              class QMdiArea;
              }

              class A_BT_TAB_DIALOG_EXT : public QWidget
              {
              Q_OBJECT

              public:
              explicit A_BT_TAB_DIALOG_EXT(QWidget *parent = nullptr);
              ~A_BT_TAB_DIALOG_EXT();

              private:
              Ui::A_BT_TAB_DIALOG_EXT *ui;

              // 3 define / declare members / parameters
              
              QLabel \*m\_status = nullptr;
              QMdiArea \*m\_mdiarea = nullptr;
              QSerialPort \*m\_serial = nullptr;
              

              };

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              What is the definition of m_TAB_Ext? It looks like it, or m_serial, is looking for a function reference/pointer, but you are passing it a pointer to a A_BT_TAB_DIALOG_EXT object.

              1 Reply Last reply
              0
              • L Lost User

                I am seriously trying to learn more about C++_. I did add a new class to the constructor, just following an examples , and I do not understand why I am getting this error. My own add is duplicate of existing , working class, and I do no see why it does no like the pointer.

                     m\_serial(new QSerialPort(this),
                       // sequence 1\` st add HERE
                        m\_TAB\_Ext(new A\_BT\_TAB\_DIALOG\_EXT)
                

                /mnt/A_BT_DEC10/A_APR13_APR15/A_APR9_MAR7_MAR19_CLEAN/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:3088: error: called object type 'A_BT_TAB_DIALOG_EXT *' is not a function or function pointer
                mainwindow_Bluetooth_copy.cpp:3088:22: error: called object type 'A_BT_TAB_DIALOG_EXT *' is not a function or function pointer
                m_TAB_Ext(new A_BT_TAB_DIALOG_EXT())
                ~~~~~~~~~^

                here is my class declaration

                namespace Ui {
                class A_BT_TAB_DIALOG_EXT;
                // add forward declarations ??
                class QMdiArea;
                }

                class A_BT_TAB_DIALOG_EXT : public QWidget
                {
                Q_OBJECT

                public:
                explicit A_BT_TAB_DIALOG_EXT(QWidget *parent = nullptr);
                ~A_BT_TAB_DIALOG_EXT();

                private:
                Ui::A_BT_TAB_DIALOG_EXT *ui;

                // 3 define / declare members / parameters
                
                QLabel \*m\_status = nullptr;
                QMdiArea \*m\_mdiarea = nullptr;
                QSerialPort \*m\_serial = nullptr;
                

                };

                B Offline
                B Offline
                BernardIE5317
                wrote on last edited by
                #8

                May I please inquire what is a Q_OBJECT .

                L 1 Reply Last reply
                0
                • B BernardIE5317

                  May I please inquire what is a Q_OBJECT .

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #9

                  Here are all parameters definitions (?) PS There are no other errors / issues . So what is

                  QSerialPort *m_serial = nullptr;

                  contributing to the issue / error and why is it part of the discussion? ( just asking )

                  private:
                  // sequence 4th*
                  public:
                  A_BT_TAB_DIALOG_EXT *m_TAB_Ext = nullptr;

                  private:
                  
                      void showStatusMessage(const QString &message);
                      Ui::MainWindow\_Bluetooth \*m\_ui = nullptr;
                      // add MDIarea ??
                      QMdiArea  \*m\_mdiarea = nullptr;
                  
                      QLabel \*m\_status = nullptr;
                      Console \*m\_console = nullptr;
                      SettingsDialog \*m\_settings = nullptr;
                      QSerialPort \*m\_serial = nullptr;
                  
                  
                      // STEP 2 define class ??
                      // spelling error  !!!
                      SettingsDialog\_RFcomm \*m\_settings\_RFcomm = nullptr;
                  
                  B 1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    Quote:

                    m_serial(new QSerialPort(this), // sequence 1` st add HERE m_TAB_Ext(new A_BT_TAB_DIALOG_EXT)

                    Which of the overloaded constructors of the QSerialPort class are you trying to call? Could you please show full details of m_TAB_Ext variable?

                    "In testa che avete, Signor di Ceprano?" -- Rigoletto

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #10

                    SOLVED THANKS, you have a very nice , positive , constructive way to lead to solution.

                    1 Reply Last reply
                    0
                    • L Lost User

                      Here are all parameters definitions (?) PS There are no other errors / issues . So what is

                      QSerialPort *m_serial = nullptr;

                      contributing to the issue / error and why is it part of the discussion? ( just asking )

                      private:
                      // sequence 4th*
                      public:
                      A_BT_TAB_DIALOG_EXT *m_TAB_Ext = nullptr;

                      private:
                      
                          void showStatusMessage(const QString &message);
                          Ui::MainWindow\_Bluetooth \*m\_ui = nullptr;
                          // add MDIarea ??
                          QMdiArea  \*m\_mdiarea = nullptr;
                      
                          QLabel \*m\_status = nullptr;
                          Console \*m\_console = nullptr;
                          SettingsDialog \*m\_settings = nullptr;
                          QSerialPort \*m\_serial = nullptr;
                      
                      
                          // STEP 2 define class ??
                          // spelling error  !!!
                          SettingsDialog\_RFcomm \*m\_settings\_RFcomm = nullptr;
                      
                      B Offline
                      B Offline
                      BernardIE5317
                      wrote on last edited by
                      #11

                      I inquire re/ Q_OBJECT because I do not understand why the compiler does not report an error re/ its usage in the code as written as I assume it is either the name of a type perhaps a class type or an identifier of an object of some type. In either case it would of course be a syntax error exempli gratia as per below:

                      class cfoo
                      {
                      int // syntax error
                      public:
                      void foo();
                      }

                      Likewise it is a syntax error to write the identifier of an object without a type specifier exempli gratia as per below:

                      class cfoo
                      {
                      xyz // syntax error
                      public:
                      void foo();
                      }

                      Perhaps Q_OBJECT is a macro hiding these details. In conclusion I do not see the answer to my inquiry.

                      L 1 Reply Last reply
                      0
                      • B BernardIE5317

                        I inquire re/ Q_OBJECT because I do not understand why the compiler does not report an error re/ its usage in the code as written as I assume it is either the name of a type perhaps a class type or an identifier of an object of some type. In either case it would of course be a syntax error exempli gratia as per below:

                        class cfoo
                        {
                        int // syntax error
                        public:
                        void foo();
                        }

                        Likewise it is a syntax error to write the identifier of an object without a type specifier exempli gratia as per below:

                        class cfoo
                        {
                        xyz // syntax error
                        public:
                        void foo();
                        }

                        Perhaps Q_OBJECT is a macro hiding these details. In conclusion I do not see the answer to my inquiry.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #12

                        Sorry , I got sidetracked fixing the issue. I have been told , not just advised, NOT to post Qt questions. Since I am not welcomed to do so I , on my own, do not want to discuss Qt here. I think that is fair. Cheers

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups