October 20, 2011

petergeng petergeng
Lab Rat
16 posts

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)

2 replies

October 20, 2011

Andre Andre
Robot Herder
6413 posts

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

October 21, 2011

Lukas Geyer Lukas Geyer
Lab Rat
2074 posts

petergeng wrote:
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?

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.

 
  ‹‹ Size of PDF files generated with Qt      Failed at rewriting a simple HTTP request with QNetworkAccessManager (formely written with curl) ››

You must log in to post a reply. Not a member yet? Register here!