Results 1 to 5 of 5

Thread: class calling other class functions?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: class calling other class functions?

    'verifica' isn't a static member function so where is your class instance variable?

  2. #2
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: class calling other class functions?

    is posted in newbie section...i don't know what you mean

  3. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: class calling other class functions?

    He meant that you can't do this:
    Qt Code:
    1. void Button::apasat()
    2. {
    3. MyWidget::verifica(y,x);
    4. }
    To copy to clipboard, switch view to plain text mode 

    You need to create an object of type MyWidget, something like this:
    Qt Code:
    1. MyWidget obj; //create an instance of MyWidget class
    2. obj.verifica(); // run the member function;
    To copy to clipboard, switch view to plain text mode 

    An if MyWidget is an GUI widget you might want to allocate memory on the heap for objects, like this:
    Qt Code:
    1. MyWidget *ptr = new MyWidget(parent); //alocate with "new" and give a parent
    2. ptr->verifica(); // call member function with pointer
    To copy to clipboard, switch view to plain text mode 

    If you don't understand take at least a tutorial of c++ first, and than a Qt one (or Qt examples), but i strongly recommend a book.

Similar Threads

  1. QtConncurrent - calling function within the class
    By jacek_ in forum Qt Programming
    Replies: 5
    Last Post: 28th October 2009, 17:37
  2. calling Gui treeWidget in Thread class
    By santosh.kumar in forum Qt Programming
    Replies: 2
    Last Post: 16th May 2007, 09:14
  3. DLL exporting functions, variables, class
    By Shuchi Agrawal in forum Newbie
    Replies: 1
    Last Post: 25th April 2007, 11:40
  4. class functions are not listing [ in VC++ editor]
    By joseph in forum Qt Programming
    Replies: 8
    Last Post: 4th April 2007, 11:43
  5. Static functions and class members
    By Raistlin in forum General Programming
    Replies: 5
    Last Post: 22nd December 2006, 10:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.