Calling functions from one class to another



  • I am working in one class (named 'ModelBrowserTree') and want to pass some information to another class (named 'Dialog')that i've created. However, in the function call it seems that only objects are allowed in this passing process... why this is? is this necessary? how can i bypass this?

    the function call while in a member function of ModelBrowserTree i have is:
    Dialog::ModelChangedInfo(docAnno);

    ModelChangedInfo is a member function of Dialog, and docAnno is a string........
    QString ModelChangedInfo(QString str)



  • This is really, really basic C++, that has nothing to do with Qt. Please pick up any basic C++ book to get started.



  • [quote author="petergeng" date="1319129803"]However, in the function call it seems that only objects are allowed in this passing process... why this is? is this necessary? how can i bypass this?[/quote]
    Well - it isn't. The call fails in your case because ModelChangedInfo() is a non-static method. So you either make it a static method (which is what you most probably do not want) or you call ModelChangedInfo() on an object of Dialog.

    If you do not know what I am talking about you should seriously consider what Andre said. Qt absolutely requires you to have at least a basic understanding of C++. If there are any specific (and Qt-related) questions feel free to come back here.


Log in to reply
 

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