Results 1 to 5 of 5

Thread: Basic question

  1. #1
    Join Date
    Dec 2009
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Basic question

    Hello

    I really don't understand how to do this thing :

    Qt Code:
    1. QTimer::singleShot(1000,this,SLOT(dati("abc")));
    2. QTimer::singleShot(2000,this,SLOT(dati("dfg")));
    3. QTimer::singleShot(2000,this,SLOT(dati("hil")));
    4.  
    5. void SslClient::dati(QString testo) {
    6. appendString(testo + "\n");
    7. .........
    8. }
    To copy to clipboard, switch view to plain text mode 

    obiovusly this is a semplification of what I need to do ...

    I found into the forum similar question ( how to pass arguments ) ... but I need a very simple explanation becouse I'm starting now with Qt creator (before I used gambas for linux and it was very simplier ) and the help didn't clarify my doubt . I think also becouse of my bad english


    Thank you in advance

  2. #2
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Basic question

    Look here please. Also, make use of the assistant and/or forum search function is nice idea, isn't it?

  3. #3
    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: Basic question

    Use QSignalMapper.

    Qt Code:
    1. QSignalMapper *mapper = new QSignalMapper(this);
    2. QTimer *t1 = new QTimer(this);
    3. QTimer *t2 = new QTimer(this);
    4. QTimer *t3 = new QTimer(this);
    5. t1->setSingleShot(true);
    6. t2->setSingleShot(true);
    7. t3->setSingleShot(true);
    8. connect(t1, SIGNAL(timeout()), mapper, SLOT(map()));
    9. connect(t2, SIGNAL(timeout()), mapper, SLOT(map()));
    10. connect(t3, SIGNAL(timeout()), mapper, SLOT(map()));
    11. connect(mapper, SIGNAL(mapped(QString)), this, SLOT(dati(QString)));
    12. mapper->setMapping(t1, "abc");
    13. mapper->setMapping(t2, "def");
    14. mapper->setMapping(t3, "ghi");
    15. t1->start(1000);
    16. t2->start(2000);
    17. t3->start(3000);
    To copy to clipboard, switch view to plain text mode 
    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. The following user says thank you to wysota for this useful post:

    giacomelli.fabio (17th December 2009)

  5. #4
    Join Date
    Dec 2009
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Basic question

    mhmhmh a lot of code to do a so little thing ......
    to pass an argument ....

    Should I forget VB and it's simplicity ?

    @ Tanuki-no Torigava I had already seen the post you linked , but I didn't understand nothing ! My english is not very good, so many little post, with various pieces of code ( i'm not good also qith qt creator ) make confusion . wysota's post is very clear

  6. #5
    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: Basic question

    Quote Originally Posted by giacomelli.fabio View Post
    Should I forget VB and it's simplicity ?
    Yes, you should. Otherwise you'll be able to do only simple things and will never go beyond that. You can shorten my code by using a loop if you really want or you can avoid using signal mapper and do things the crude way - using a custom slot that will call the function with appropriate parameters.
    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.


Similar Threads

  1. Basic QTreeView DragNDrop Question
    By iraytrace in forum Newbie
    Replies: 1
    Last Post: 7th October 2009, 13:15
  2. Basic QtScript question
    By jimboqt in forum Newbie
    Replies: 0
    Last Post: 23rd September 2008, 14:09
  3. Replies: 2
    Last Post: 21st February 2008, 22:35
  4. Basic question on new and delete
    By jcr in forum General Programming
    Replies: 25
    Last Post: 14th February 2006, 15:09
  5. Using QSA: A very basic question
    By yogeshm02 in forum Newbie
    Replies: 3
    Last Post: 26th January 2006, 07:34

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.