what do you think I meant when I wrote
//Q_OBJECT etc
in the class code?
It means you have to fill in some bits for yourself! Now, please go and have a try for yourself!
what do you think I meant when I wrote
//Q_OBJECT etc
in the class code?
It means you have to fill in some bits for yourself! Now, please go and have a try for yourself!
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
excuse me
what about 2'nd problem? (call a function that is member of other class)
my mapper class is :
Qt Code:
class LookUpResultHandler : QObject { Q_OBJECT; public: LookUpResultHandler(int); //constructor private: int id; public slots: };To copy to clipboard, switch view to plain text mode
and in a cpp file i wrote :
Qt Code:
#include "lookupresulthandler.h" LookUpResultHandler::LookUpResultHandler(int id):id(id) { HostLookUpResult(hi,id); //this function is not accessible here because this is member of another class (my main class) }To copy to clipboard, switch view to plain text mode
and in my main cpp file i wrote :
Qt Code:
LookUpResultHandler *lrh = new LookUpResultHandler(id);To copy to clipboard, switch view to plain text mode
just according your approach !
BUT give me ERROR !!!
why?????
Life is about making the right decisions and moving on.
hi Mr Wysota
i knew this code is wrong but Mr amleto say this is correct.
i'm wait to amleto to relpy me
thanks Mr wysota
Life is about making the right decisions and moving on.
you already know that method is from another class. So I leave up to you to figure out how to solve this issue.
by the way,
That is not a valid constructor.Qt Code:
LookUpResultHandler::LookUpResultHandler(int id):id(id)To copy to clipboard, switch view to plain text mode
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
i add a QObject *ReturnHandle to second class. by the following:
Qt Code:To copy to clipboard, switch view to plain text mode
and in my main cpp file i wrote:
and for definition of lookupresult, i wrote:Qt Code:
LookUpResultHandler *lrh = new LookUpResultHandler(this,id);To copy to clipboard, switch view to plain text mode
but give me error on second line in my main cppQt Code:
{ ReturnHandle->HostLookUpResult(hi,id); }To copy to clipboard, switch view to plain text mode
the error is: 'QObject' is inaccessible base of 'LookupResultHandler'
my problem is this ! what can i do ??
if needed i attach my project ?
Life is about making the right decisions and moving on.
my first try would be this:
class LookUpResultHandler : public QObject
For future reference, if you are going to say 'line two gives me an error', it is probably somewhat helpful if you actually show line 2
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
now i tried by "public : QObject"
but give the error:
the 'QObject' has no member that named 'HostLookUpResult'
Last edited by Ali Reza; 26th November 2012 at 17:01. Reason: updated contents
Life is about making the right decisions and moving on.
have you looked at QObject docs? Please do. If you look at the docs and find a method named HostLookUpResult, then you may think about writing a bug report to Qt. Otherwise you may want to think about why your code is wrong, and what the ccompiler is telling you.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
dear amleto plz tell me how i call that function ?
Life is about making the right decisions and moving on.
Ali Reza, please tell me, how much experience with C++ do you have? As it seems you have completely none. All the "problems" here are related more to C++ than to Qt, the fact that we're talking about Qt classes here is completely irrelevant. Maybe you should read some book on C++ programming and spend a week or two on practising use of the language? It would really save you a lot of time.
you are right Mr wysota
i am newbie to C++ and Qt. because i am a student with 16 years old. and you are instructor and master.
thanks for your advice
Life is about making the right decisions and moving on.
well done on reading the thread
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
finally i solved my problem by signal&slot mechanism .
thanks Mr amleto
Life is about making the right decisions and moving on.
Bookmarks