Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object
Forum Updated to NodeBB v4.3 + New Features

error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object

Scheduled Pinned Locked Moved Unsolved C++ Gurus
6 Posts 3 Posters 798 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on 19 Jul 2022, 14:27 last edited by Anonymous_Banned275
    #1

    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))
    | ~~~~~~~~~~~~~^~

    J 1 Reply Last reply 19 Jul 2022, 15:35
    0
    • A Anonymous_Banned275
      19 Jul 2022, 14:27

      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))
      | ~~~~~~~~~~~~~^~

      J Offline
      J Offline
      JonB
      wrote on 19 Jul 2022, 15:35 last edited by JonB
      #2

      @AnneRanch
      You have line

      if(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))
      
      J 1 Reply Last reply 20 Jul 2022, 05:55
      1
      • J JonB
        19 Jul 2022, 15:35

        @AnneRanch
        You have line

        if(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))
        
        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 20 Jul 2022, 05:55 last edited by
        #3

        @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))
        

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

        J 1 Reply Last reply 20 Jul 2022, 07:25
        2
        • J jsulm
          20 Jul 2022, 05:55

          @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))
          
          J Offline
          J Offline
          JonB
          wrote on 20 Jul 2022, 07:25 last edited by
          #4

          @jsulm Sorry, thanks, corrected.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Anonymous_Banned275
            wrote on 20 Jul 2022, 15:40 last edited by
            #5

            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

            J 1 Reply Last reply 21 Jul 2022, 06:17
            0
            • A Anonymous_Banned275
              20 Jul 2022, 15:40

              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

              J Offline
              J Offline
              JonB
              wrote on 21 Jul 2022, 06:17 last edited by
              #6

              @AnneRanch
              For equivalence of old QRegExp::exactMatch() use QRegularExpression::match() but change the regular expression pattern to have ^ at the start and $ at the end (like QRegularExpression re("^this is an exact match$")).

              1 Reply Last reply
              1

              1/6

              19 Jul 2022, 14:27

              • Login

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