Results 1 to 5 of 5

Thread: a quetion about signals and slots

  1. #1
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question a quetion about signals and slots

    I started with signals and slots follwing the exercise at zetcode

    button.clicked.connect(self.onClicked)

    button = QGui.QPushButton()

    if button is the object created

    then what is clicked and connect

    from what i understand if clicked is an event that occurred, so is it method defined inside QPushButton ?

    what is connect then ?

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

    Default Re: a quetion about signals and slots

    clicked will represent the signal. connect is a method to join a signal to a slot
    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.

  3. #3
    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: a quetion about signals and slots

    Quote Originally Posted by krystosan View Post
    from what i understand if clicked is an event that occurred, so is it method defined inside QPushButton ?
    As amleto already said, "clicked" is what Qt calls a signal. Your guess was already very good, you can think of it as a high level event that the button sends whenever it is clicked and your assumption that it is implemented in the button class is also correct (not in QPushButton though, but in QPushButton's base class QAbstractButton).


    Quote Originally Posted by krystosan View Post
    what is connect then ?
    Again as amleto said, it is a method to tell Qt which function you would like to get executed when the "clicked" signal/event happens.

    Cheers,
    _

  4. #4
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: a quetion about signals and slots

    so can i think of clicked method sort of pure virtual function of C++

  5. #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: a quetion about signals and slots

    Quote Originally Posted by krystosan View Post
    so can i think of clicked method sort of pure virtual function of C++
    No, it's neither pure nor virtual. It's just a method declared in a class and implemented by a special tool called Meta-Object Compiler that is executed when Qt is built.
    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. QT SIGNALS and SLOTS
    By beginQT in forum Newbie
    Replies: 7
    Last Post: 23rd September 2011, 15:40
  2. Signals and Slots
    By Maluko_Da_Tola in forum Newbie
    Replies: 3
    Last Post: 30th July 2010, 00:57
  3. Signals & Slots!
    By qtoptus in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2010, 02:50
  4. Signals and Slots
    By 83.manish in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 11:31
  5. Signals and Slots in dll
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2006, 09:12

Tags for this Thread

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.