Page 2 of 2 FirstFirst 12
Results 21 to 36 of 36

Thread: QSignalMapper

  1. #21
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSignalMapper

    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.

  2. #22
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: QSignalMapper

    excuse me

    what about 2'nd problem? (call a function that is member of other class)

    my mapper class is :
    Qt Code:
    1. class LookUpResultHandler : QObject
    2. {
    3. Q_OBJECT;
    4. public:
    5. LookUpResultHandler(int); //constructor
    6.  
    7. private:
    8. int id;
    9.  
    10. public slots:
    11. void lookupresult(QHostInfo);
    12.  
    13. };
    To copy to clipboard, switch view to plain text mode 

    and in a cpp file i wrote :
    Qt Code:
    1. #include "lookupresulthandler.h"
    2.  
    3. LookUpResultHandler::LookUpResultHandler(int id):id(id)
    4.  
    5. void LookUpResultHandler::lookupresult(QHostInfo hi)
    6. {
    7. HostLookUpResult(hi,id); //this function is not accessible here because this is member of another class (my main class)
    8. }
    To copy to clipboard, switch view to plain text mode 

    and in my main cpp file i wrote :
    Qt Code:
    1. LookUpResultHandler *lrh = new LookUpResultHandler(id);
    2. QHostInfo::lookupHost(rp.getHost(),lrh,SLOT(lookupresult(QHostInfo)));
    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.

  3. #23
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSignalMapper

    Quote Originally Posted by Ali Reza View Post
    BUT give me ERROR !!!
    why?????
    You answered this question yourself -- because it is not accessible as it is member of another class. Adjust your code accordingly. It's a basic programming issue and you should be able to solve it with basic programming skills.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #24
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: QSignalMapper

    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.

  5. #25
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSignalMapper

    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,
    Qt Code:
    1. LookUpResultHandler::LookUpResultHandler(int id):id(id)
    To copy to clipboard, switch view to plain text mode 
    That is not a valid constructor.
    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.

  6. #26
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSignalMapper

    Quote Originally Posted by Ali Reza View Post
    i knew this code is wrong but Mr amleto say this is correct.
    It is correct (as far as the logic is concerned, at least). It is just different than your actual code. Usually this is called "pseudo-code". If you never heard that term before, search for it using your favourite web search engine.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #27
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: QSignalMapper

    i add a QObject *ReturnHandle to second class. by the following:
    Qt Code:
    1. class LookUpResultHandler : QObject
    2. {
    3. Q_OBJECT;
    4. public:
    5. LookUpResultHandler(QObject *,int);
    6.  
    7. private:
    8. int id;
    9. QObject *ReturnHandle;
    10.  
    11. public slots:
    12. void lookupresult(QHostInfo);
    13.  
    14. };
    To copy to clipboard, switch view to plain text mode 

    and in my main cpp file i wrote:
    Qt Code:
    1. LookUpResultHandler *lrh = new LookUpResultHandler(this,id);
    2. QHostInfo::lookupHost(rp.getHost(),lrh,SLOT(lookupresult(QHostInfo)));
    To copy to clipboard, switch view to plain text mode 
    and for definition of lookupresult, i wrote:
    Qt Code:
    1. LookUpResultHandler::LookUpResultHandler(QObject *rh,int id):id(id) , ReturnHandle(rh){}
    2.  
    3. void LookUpResultHandler::lookupresult(QHostInfo hi)
    4. {
    5. ReturnHandle->HostLookUpResult(hi,id);
    6. }
    To copy to clipboard, switch view to plain text mode 
    but give me error on second line in my main cpp
    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.

  8. #28
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSignalMapper

    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.

  9. #29
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: QSignalMapper

    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.

  10. #30
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSignalMapper

    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.

  11. #31
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: QSignalMapper

    dear amleto plz tell me how i call that function ?
    Life is about making the right decisions and moving on.

  12. #32
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSignalMapper

    Quote Originally Posted by Ali Reza View Post
    dear amleto plz tell me how i call that function ?
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #33
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: QSignalMapper

    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.

  14. #34
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSignalMapper

    Quote Originally Posted by Ali Reza View Post
    1.you define a new class that named "MyMapper" that inherits "QObject". but this definition get me the following error:
    " 'QObject' is an inaccessible base of 'MyMapper' ".
    That's because of the private inheritance. Just dervice publically from QObject

    Cheers,
    _

  15. #35
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSignalMapper

    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.

  16. #36
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: QSignalMapper

    finally i solved my problem by signal&slot mechanism .
    thanks Mr amleto
    Life is about making the right decisions and moving on.

Similar Threads

  1. qSignalMapper gets no output
    By saman_artorious in forum Qt Programming
    Replies: 10
    Last Post: 31st July 2012, 09:00
  2. QSignalMapper
    By axisdj in forum Newbie
    Replies: 6
    Last Post: 16th September 2010, 01:52
  3. QSignalMapper and argument problems
    By harmodrew in forum Newbie
    Replies: 14
    Last Post: 7th August 2010, 19:20
  4. help with QSignalMapper and actions
    By andreime in forum Newbie
    Replies: 1
    Last Post: 9th August 2009, 18:24
  5. ? about QSignalMapper
    By JimDaniel in forum Qt Programming
    Replies: 1
    Last Post: 13th January 2008, 21:21

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.