cannot call member function 'void Additem::FunctAddToDb()' without object



  • Hi,

    I'm trying to call a function Additem::FunctAddToDb () from review.cpp.

    The code:

    Additem.h

    namespace Ui {
    class Additem;
    }
    
    class Additem : public QDialog
    {
        Q_OBJECT
    
    public:
    
        //db
        QSqlDatabase db;
    
       explicit Additem(QWidget *parent = 0);
        ~Additem();
    
    //Functions
       void FunctAddToDb();
    

    review.cpp

    Additem::FunctAddToDb ();
    

    When I run it, I get the following error message:

    C:\Programming\Projects\Folkfriends\review.cpp:58: error: cannot call member function 'void Additem::FunctAddToDb()' without object
    Additem::FunctAddToDb ();

    What am I missing here? Thank you.



  • either you make the method static or you first instantiate Additem and then call that method.



  • Thank you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.