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
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.6k 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.
  • G Offline
    G Offline
    gabor53
    wrote on 5 May 2016, 14:41 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
    • V Offline
      V Offline
      VRonin
      wrote on 5 May 2016, 16:34 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 6 May 2016, 03:07 last edited by
        #3

        Thank you.

        1 Reply Last reply
        0

        3/3

        6 May 2016, 03:07

        • Login

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