Results 1 to 3 of 3

Thread: Issue connecting QButtonGroup with a function

  1. #1
    Join Date
    Sep 2009
    Posts
    60
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Issue connecting QButtonGroup with a function

    I have a bunch of buttons in a QButtonGroup that I am trying to connect with a function.


    Here is my code:

    Qt Code:
    1. def __init__(self):
    2. addAppButtonGroup = QButtonGroup()
    3. addAppButtonGroup.addButton(addCustomAppButton)
    4. addAppButtonGroup.addButton(addAppleStoreAppButton)
    5. addAppButtonGroup.addButton(addWebLinkButton)
    6.  
    7. addAppButtonGroup.setId(addCustomAppButton, 0)
    8. addAppButtonGroup.setId(addAppleStoreAppButton, 1)
    9. addAppButtonGroup.setId(addWebLinkButton, 2)
    10.  
    11. ""Stuff to make buttons show up"""
    12.  
    13. self.connect(addAppButtonGroup, SIGNAL("buttonClicked(int)"), self.AddApplication)
    14.  
    15. def AddApplication(self, id):
    16. print "hi"
    17. print id
    To copy to clipboard, switch view to plain text mode 


    So all the buttons show up and I can click on them. However, when I click on them, nothing is printed to the screen.


    Thanks.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Issue connecting QButtonGroup with a function

    As a QtC++ programmer, I can say couple of things
    1. You are missing SLOT() macro
    2. Even if the slot gets called, the id variable will not be valid, as you have not mentioned the required signature in connect.
    3. More over you cannot connect a signal with less parameters to slot with more parameters.
    4. A slot should always have less than or equal number of parameters, as compared to the number of parameters of signal, and also all the type of the parameters should match

  3. #3
    Join Date
    Sep 2009
    Posts
    60
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Issue connecting QButtonGroup with a function

    Quote Originally Posted by Santosh Reddy View Post
    As a QtC++ programmer, I can say couple of things
    1. You are missing SLOT() macro
    2. Even if the slot gets called, the id variable will not be valid, as you have not mentioned the required signature in connect.
    3. More over you cannot connect a signal with less parameters to slot with more parameters.
    4. A slot should always have less than or equal number of parameters, as compared to the number of parameters of signal, and also all the type of the parameters should match
    All of this does not apply in Python.

    I was able to fix my issue by changing all of the
    Qt Code:
    1. addAppButtonGroup
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. self.addAppButtonGroup
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 3
    Last Post: 6th April 2011, 19:00
  2. Replies: 2
    Last Post: 13th June 2010, 12:41
  3. Replies: 4
    Last Post: 27th November 2009, 13:00
  4. connecting issue with QAbstractItemModel
    By dave_mm0 in forum Qt Programming
    Replies: 3
    Last Post: 29th July 2009, 14:01
  5. Replies: 2
    Last Post: 5th June 2008, 21:32

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.