Results 1 to 5 of 5

Thread: call different slots each time 'pushbutton' is clicked

  1. #1
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Post call different slots each time 'pushbutton' is clicked

    Hi everyone,
    Is it possible to call different slots each time a 'PushButton' is clicked.
    Like,I have a button 'slideshow',When I click it the first time,I want the slideshow to start and when I click the 'slideshow' button the second time,the slideshow should stop.
    Could someone give me some idea and hints on how to implement it ,if possible.
    Thanks in advance.
    If everything seems to be going well, you have obviously overlooked something.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: call different slots each time 'pushbutton' is clicked

    Why don't you implement the logic in your slot. If the slideshow is not running, you'll start it. If the slideshow is running, you'll stop it.
    J-P Nurmi

  3. #3
    Join Date
    Nov 2008
    Posts
    142
    Thanks
    3
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: call different slots each time 'pushbutton' is clicked

    What jpn suggested is probably the best, and cleanest, solution to your problem.

    But, just for the sake of completeness, I want to point out the connect / disconnect pair of signal handling methods. If you want to separate the functionality into different slots, you could use this methods to do so. Just disconnect the "Start" slot from the button and connect to the "Stop" slot, and vice versa.

  4. #4
    Join Date
    Nov 2008
    Posts
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Re: call different slots each time 'pushbutton' is clicked

    In your class take a static boolean variable, initialised with FALSE.
    When you click for the first time set it to TRUE i.e. SlideShow running and clicking on 2nd time set it to FALSE i.e. SlideShow stopped.

    Hope this solution works for you!!!

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: call different slots each time 'pushbutton' is clicked

    This might also help you .

Similar Threads

  1. what if qthread call same slot at the same time?
    By zl2k in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2008, 09:58

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.