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".
ThanksCODE
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))
| ~~~~~~~~~~~~~~^ -
@AnneRanch
You have lineif(QRegExp::exactMatch(source))
just below
//#ifdef BYPASS
.The error message states that
QRegExp::exactMatch()
can only be called in an instance/object, like:QRegExp re("..."); if(re.exactMatch(source))
-
@JonB said in error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object:
if(re::exactMatch(source))
Small correction:
if(re.exactMatch(source))
-
Thanks for helping to understand the basic error I have made. Problem solved.
Unfortunately QRegExp in now QRegularExpression and has no "exactMatch".
But the concept is still same.Thanks
-
@AnneRanch
For equivalence of oldQRegExp::exactMatch()
useQRegularExpression::match()
but change the regular expression pattern to have^
at the start and$
at the end (likeQRegularExpression re("^this is an exact match$")
).