how to add new class ?
-
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
-
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)
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_OBJECTpublic:
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
-
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)
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
-
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_OBJECTpublic:
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;
};
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 ofm_TAB_Ext
variable?"In testa che avete, Signor di Ceprano?" -- Rigoletto
-
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_OBJECTpublic:
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;
};
-
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_OBJECTpublic:
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;
};
May I please inquire what is a
Q_OBJECT
. -
May I please inquire what is a
Q_OBJECT
.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;
-
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 ofm_TAB_Ext
variable?"In testa che avete, Signor di Ceprano?" -- Rigoletto
-
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;
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. -
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.