error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object
-
I do not understand why I am getting this error. Can somebody smarter than me explain it and help me solve it. Does it have anything to do the code is a shared library? When I bypass the if() code debugger shows valid "source". Thanks CODE QString BT_Utility_Library::Write_Data ( QString source, // data to write QString destination, // to where - filename, QTextEdit *OUTPUT_TextEdit, // to where as text - TAb QTextEdit *TRACE_TextEdit // debug / trace as text ) { // TODO just a placeholder for now not sure who is writing the TAB QString text = ""; // until bug fixed local #ifdef TASK //ui->textEdit_19->clear(); text += "\n\tSUB_TASK \tupdate Commmand TAB or database ... \n "; text += Q_FUNC_INFO ; //text += "\nCommand "; //text += arg1; text += "\n\t@line "; text += QString::number(LINE); //text += "\nLAST TASK CODED HERE "; TRACE_TextEdit->append (text); #endif // validate OUTPUT_TextEdit //bool QRegExp::exactMatch(OUTPUT_TextEdit); const // CONVERT TO myTextEdit->plainText().isEmpty() //#ifdef BYPASS if(QRegExp::exactMatch(source)) { // Command detected #ifdef TASK QColor color = QColor( "red" ); //ui->textEdit_19->clear(); text += "\n\tSUB_TASK \tCommand detected \n "; text += Q_FUNC_INFO ; //text += "\nCommand "; //text += arg1; text += "\n\t@line "; text += QString::number(LINE); //text += "\nLAST TASK CODED HERE "; TRACE_TextEdit->append (text); color = QColor( "black" ); #endif } // #endif // read data back return text; }; ERROR /mnt/MDI_RAID_5/MDI_WORK_COPY_FOLDER/MDI_BT_JULY_19_1/LoCAL_SOURCE/BT_Utility_Library/bt_utility_library.cpp:83: error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object bt_utility_library.cpp: In member function ‘QString BT_Utility_Library::Write_Data(QString, QString, QTextEdit*, QTextEdit*)’: bt_utility_library.cpp:83:26: error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object 83 | if(QRegExp::exactMatch(source)) | ~~~~~~~~~~~~~^~
-
I do not understand why I am getting this error. Can somebody smarter than me explain it and help me solve it. Does it have anything to do the code is a shared library? When I bypass the if() code debugger shows valid "source". Thanks CODE QString BT_Utility_Library::Write_Data ( QString source, // data to write QString destination, // to where - filename, QTextEdit *OUTPUT_TextEdit, // to where as text - TAb QTextEdit *TRACE_TextEdit // debug / trace as text ) { // TODO just a placeholder for now not sure who is writing the TAB QString text = ""; // until bug fixed local #ifdef TASK //ui->textEdit_19->clear(); text += "\n\tSUB_TASK \tupdate Commmand TAB or database ... \n "; text += Q_FUNC_INFO ; //text += "\nCommand "; //text += arg1; text += "\n\t@line "; text += QString::number(LINE); //text += "\nLAST TASK CODED HERE "; TRACE_TextEdit->append (text); #endif // validate OUTPUT_TextEdit //bool QRegExp::exactMatch(OUTPUT_TextEdit); const // CONVERT TO myTextEdit->plainText().isEmpty() //#ifdef BYPASS if(QRegExp::exactMatch(source)) { // Command detected #ifdef TASK QColor color = QColor( "red" ); //ui->textEdit_19->clear(); text += "\n\tSUB_TASK \tCommand detected \n "; text += Q_FUNC_INFO ; //text += "\nCommand "; //text += arg1; text += "\n\t@line "; text += QString::number(LINE); //text += "\nLAST TASK CODED HERE "; TRACE_TextEdit->append (text); color = QColor( "black" ); #endif } // #endif // read data back return text; }; ERROR /mnt/MDI_RAID_5/MDI_WORK_COPY_FOLDER/MDI_BT_JULY_19_1/LoCAL_SOURCE/BT_Utility_Library/bt_utility_library.cpp:83: error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object bt_utility_library.cpp: In member function ‘QString BT_Utility_Library::Write_Data(QString, QString, QTextEdit*, QTextEdit*)’: bt_utility_library.cpp:83:26: error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object 83 | if(QRegExp::exactMatch(source)) | ~~~~~~~~~~~~~^~
You asked
Member 14968771 wrote:
Can somebody smarter than me explain it and help me solve it.
You don't need someone smarter - you just need to read the error message and think about what it is telling you. I am not a C++ programmer, but it looks like you are trying to see if the contents of variable 'source' matches a pattern in a Regular Expression. However, this has no meaning because the system cannot possibly guess what pattern you want it to match against as you have not told it what pattern you want. My guess is that QRegExp is a class for regular expressions; so you will have to instantiate it, telling it (either in the constructor call or in a method of the instantiated object) what the Regular Expression that you wish to use is. The error message that you have got is the compiler telling you that you are trying to run a member function (i.e. a method of a class) without having created an object and the function needs an object to use (which presumably has been told what Regular Expression pattern you are wanting to use for the comparison).
-
I do not understand why I am getting this error. Can somebody smarter than me explain it and help me solve it. Does it have anything to do the code is a shared library? When I bypass the if() code debugger shows valid "source". Thanks CODE QString BT_Utility_Library::Write_Data ( QString source, // data to write QString destination, // to where - filename, QTextEdit *OUTPUT_TextEdit, // to where as text - TAb QTextEdit *TRACE_TextEdit // debug / trace as text ) { // TODO just a placeholder for now not sure who is writing the TAB QString text = ""; // until bug fixed local #ifdef TASK //ui->textEdit_19->clear(); text += "\n\tSUB_TASK \tupdate Commmand TAB or database ... \n "; text += Q_FUNC_INFO ; //text += "\nCommand "; //text += arg1; text += "\n\t@line "; text += QString::number(LINE); //text += "\nLAST TASK CODED HERE "; TRACE_TextEdit->append (text); #endif // validate OUTPUT_TextEdit //bool QRegExp::exactMatch(OUTPUT_TextEdit); const // CONVERT TO myTextEdit->plainText().isEmpty() //#ifdef BYPASS if(QRegExp::exactMatch(source)) { // Command detected #ifdef TASK QColor color = QColor( "red" ); //ui->textEdit_19->clear(); text += "\n\tSUB_TASK \tCommand detected \n "; text += Q_FUNC_INFO ; //text += "\nCommand "; //text += arg1; text += "\n\t@line "; text += QString::number(LINE); //text += "\nLAST TASK CODED HERE "; TRACE_TextEdit->append (text); color = QColor( "black" ); #endif } // #endif // read data back return text; }; ERROR /mnt/MDI_RAID_5/MDI_WORK_COPY_FOLDER/MDI_BT_JULY_19_1/LoCAL_SOURCE/BT_Utility_Library/bt_utility_library.cpp:83: error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object bt_utility_library.cpp: In member function ‘QString BT_Utility_Library::Write_Data(QString, QString, QTextEdit*, QTextEdit*)’: bt_utility_library.cpp:83:26: error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object 83 | if(QRegExp::exactMatch(source)) | ~~~~~~~~~~~~~^~