Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error C2352: illegal call of non-static member function
Forum Updated to NodeBB v4.3 + New Features

Error C2352: illegal call of non-static member function

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 12.7k 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.
  • R Offline
    R Offline
    rraf02
    wrote on 10 May 2013, 13:34 last edited by
    #1

    Hi

    I am trying to modify some code that someone else wrote. Added two new UI screens.
    One is working perfectly.
    The other is working, but I need to pass data from a com port to it from another module.
    So I figured I would create a function and pass the data to it so that it could parse it and update the local ui-window.

    newsurvydialog.h

    #ifndef NEWSURVEYDIALOG_H
    #define NEWSURVEYDIALOG_H

    #include <QDialog>
    #include <QString>
    #include <QFile>
    #include <QList>
    #include <QIcon>
    #include "panelconnection.h"
    #include "common_defs.h"
    //#include "ui_newsurveydialog.h"

    namespace Ui {
    class NewSurveyDialog;
    }

    class NewSurveyDialog : public QDialog
    {
    Q_OBJECT

    public:
    explicit NewSurveyDialog(QWidget *parent = 0 ) ;
    ~NewSurveyDialog();

    void setDownloaded(bool flag);
    bool setSource(QFile &src);
    bool setSource(QString src);
    int  ConvertRSSI( char * hexRssi );
    void parseNewSurveyData( QString str );
    

    newsurveydialog.cpp

    void NewSurveyDialog::parseNewSurveyData(
    QString str
    ) {

    ui->IDC_EDIT_OUTPUT_RAW->append( str );
    

    }

    panelconnection.cpp

    mData = thread->getData().replace(request.trimmed(), tr("")).trimmed();
    qDebug() << "trimmed ==" << mData;

    mData = thread->getData();
    qDebug() << "trimmed ==" << mData;
    NewSurveyDialog::parseNewSurveyData( mData );

    Error message from compiler

    .\panelconnection.cpp(315) : error C2352: 'NewSurveyDialog::parseNewSurveyData'
    : illegal call of non-static member function
    c:\cp3000_suite_latest\src\cp3000_suite\newsurveydialog.h(29) : see declaration of 'NewSurveyDialog::parseNewSurveyData'
    NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0
    \VC\BIN\cl.EXE"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0
    \VC\BIN\nmake.exe"' : return code '0x2'
    Stop.

    Any assistance would be appreciated.

    Also is there a great book that I can order today to help bring me up to speed.

    Thanks
    Rob

    1 Reply Last reply
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on 10 May 2013, 13:47 last edited by
      #2

      you are trying to update a window for a non-existent object... You must first create an object of NewSurveyDialog type class and then call the method for that object...

      1 Reply Last reply
      0
      • R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 10 May 2013, 13:50 last edited by
        #3

        the error says it all:
        you're trying to access the member function which isn't declared as static.
        Since you are using a member inside the function you need to call the method on an instance instead of the static way (with prepended NewSurveyDialog::).

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rraf02
          wrote on 10 May 2013, 14:00 last edited by
          #4

          Thanks for the replies.

          I do create an object. I only put in some of the code.

          When I declare in newsurveydialog.h as a static

          static void parseNewSurveyData( QString str );

          I get the following compile errors.

          newsurveydialog.cpp
          .\newsurveydialog.cpp(85) : error C2227: left of '->IDC_EDIT_OUTPUT_RAW' must point to class/struct/union/generic type
          .\newsurveydialog.cpp(85) : error C2227: left of '->append' must point to class/struct/union/generic type
          NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0
          \VC\BIN\cl.EXE"' : return code '0x2'
          Stop.
          NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0
          \VC\BIN\nmake.exe"' : return code '0x2'
          Stop.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            raven-worx
            Moderators
            wrote on 10 May 2013, 14:02 last edited by
            #5

            as i wrote in my post: you are accessing a member (ui) inside this function. Thus you can't make it static.
            Because you can only access other static members out of a static method.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rraf02
              wrote on 10 May 2013, 14:03 last edited by
              #6

              Here is the code that creates the ui-> object for ui->IDC_EDIT_OUTPUT_RAW->append( str );

              NewSurveyDialog::NewSurveyDialog(QWidget *parent ) :
              QDialog(parent),
              ui(new Ui::NewSurveyDialog)
              {
              ui->setupUi(this);

              // set flags default values
              m_bNotifyPaused = FALSE;
              //nConnection = NULL;
              
              //connect(ui->buttonOK, SIGNAL(clicked()), SLOT(buttonPressedOK()));
              
              connect(ui->IDC_BUTTON_BROWSE_SAVE_SURVEY, SIGNAL(clicked()), SLOT(buttonPressedBrowseSaveSurvey()));
              
              connect(ui->StartNewSurvey, SIGNAL(clicked()), SLOT(buttonStartNewSurvey()));
              
              connect(ui->PauseAnalysis, SIGNAL(clicked()), SLOT(buttonPauseAnalysis()));
              
              
              //ui->IDC_RSSI_BARGRAPH->setVisible(false);
              
              initProgress(-115,-55);
              
              updateProgress( -115 );
              
              ui->IDC_RSSI_BARGRAPH->setVisible(true);
              
              ui->IDC_EDIT_OUTPUT_RAW->setVisible(true);
              
              ui->IDC_REPEATER_ID->insert( gRptrSerialNbr);
              
              ui->IDC_PARENT_ID->insert( gMasterID );
              
              nonJoinableCount = 0;
              

              }

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rraf02
                wrote on 10 May 2013, 14:07 last edited by
                #7

                so how do I pass a data string to newSurveyDialog ?

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  raven-worx
                  Moderators
                  wrote on 10 May 2013, 14:09 last edited by
                  #8

                  did you read my first post at all? You should use a instance to your object where you want to call the method.
                  Or you could use SIGNALS/SLOTS to send a string to another object.

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Mario84
                    wrote on 10 May 2013, 14:11 last edited by
                    #9

                    [quote author="rraf02" date="1368194601"]Here is the code that creates the ui-> object for ui->IDC_EDIT_OUTPUT_RAW->append( str );

                    NewSurveyDialog::NewSurveyDialog(QWidget *parent ) :
                    QDialog(parent),
                    ui(new Ui::NewSurveyDialog)
                    {
                    ui->setupUi(this);

                    // set flags default values
                    m_bNotifyPaused = FALSE;
                    //nConnection = NULL;
                    
                    //connect(ui->buttonOK, SIGNAL(clicked()), SLOT(buttonPressedOK()));
                    
                    connect(ui->IDC_BUTTON_BROWSE_SAVE_SURVEY, SIGNAL(clicked()), SLOT(buttonPressedBrowseSaveSurvey()));
                    
                    connect(ui->StartNewSurvey, SIGNAL(clicked()), SLOT(buttonStartNewSurvey()));
                    
                    connect(ui->PauseAnalysis, SIGNAL(clicked()), SLOT(buttonPauseAnalysis()));
                    
                    
                    //ui->IDC_RSSI_BARGRAPH->setVisible(false);
                    
                    initProgress(-115,-55);
                    
                    updateProgress( -115 );
                    
                    ui->IDC_RSSI_BARGRAPH->setVisible(true);
                    
                    ui->IDC_EDIT_OUTPUT_RAW->setVisible(true);
                    
                    ui->IDC_REPEATER_ID->insert( gRptrSerialNbr);
                    
                    ui->IDC_PARENT_ID->insert( gMasterID );
                    
                    nonJoinableCount = 0;
                    

                    }[/quote]

                    That's the code creating an ui-object...
                    but the method you're calling isn't a member of the ui-class but of your class NewSurveyDialog
                    -> that's the one you have to instantiate and call the method on its instance

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      b1gsnak3
                      wrote on 10 May 2013, 14:12 last edited by
                      #10

                      in pannel connection.cpp you must create an instance of NewSurveyDialog... For example:

                      @
                      mData = thread->getData().replace(request.trimmed(), tr(”“)).trimmed();
                      qDebug() << “trimmed ==” << mData;

                      mData = thread->getData();
                      qDebug() << “trimmed ==” << mData;
                      NewSurveyDialog *someName = new NewSurveyDialog(); // This is an instance of a object
                      somename->parseNewSurveyData(mData); // This is how you call the method for that object
                      @

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        rraf02
                        wrote on 10 May 2013, 14:14 last edited by
                        #11

                        I'm new at QT and figuring it out as I go, (Reading up and then Trial and Terror).

                        As my brother said when he was posted to Scotland, I know you are speaking english, but I don't understand a word you are saying. :-)

                        I thought I already had an instance already created as I am updating the new window, I just need to pass data to it from the com port data stream.

                        So do you have an example of how I might use SIGNALS/SLOTS to send a string from another object.
                        I will also try to read up on signals/slots.

                        BTW, thanks for the help.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          Mario84
                          wrote on 10 May 2013, 14:17 last edited by
                          #12

                          even if you really had created the instance... "NewSurveyDialog::parseNewSurveyData( mData );" is always a static member call

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            rraf02
                            wrote on 10 May 2013, 14:27 last edited by
                            #13

                            Thanks. I will give that a try.

                            1 Reply Last reply
                            0

                            2/13

                            10 May 2013, 13:47

                            11 unread
                            • Login

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