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. cannot call member function 'void Additem::FunctAddToDb()' without object
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.6k Views
  • 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.
  • G Offline
    G Offline
    gabor53
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

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

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • G Offline
        G Offline
        gabor53
        wrote on last edited by
        #3

        Thank you.

        1 Reply Last reply
        0

        • Login

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