Results 1 to 10 of 10

Thread: custom signals

  1. #1
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default custom signals

    do we have to declare smth extra to use custom signals(our own defined signals)?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: custom signals

    what do you mean? all what you need it add Q_OBJECT and emit for emitting a signal.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Dec 2007
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: custom signals

    and if you wish to use your own data type as parameter, register it with the metatype system
    Let your work talk for you

  4. #4
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: custom signals

    i declared the following signal in a class
    Qt Code:
    1. signals:
    2. void buttonClicked(int index);
    To copy to clipboard, switch view to plain text mode 

    and used the signal in a different class, to connect to a slot
    Qt Code:
    1. bool isConnect = connect(_visualBrowsingWidget->_buttonContainer, SIGNAL(buttonClicked(int index)), this, SLOT(showCorrectWidget(int index)));
    To copy to clipboard, switch view to plain text mode 

    but signal doesnt connect, saying:
    Qt Code:
    1. Object::connect: No such signal ViewButtonContainer::buttonClicked(int index)
    To copy to clipboard, switch view to plain text mode 

    i m sure i have used own signals before, so i m wondering why this is happening. do i have to declare the signal somewhere else also?

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: custom signals

    show us declaration of ViewButtonContainer.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #6
    Join Date
    Dec 2007
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: custom signals

    inside the connect statement, you should not specify the parameter name....

    connect(...SIGNAL(sometingHappened(int))....);
    Let your work talk for you

  7. The following user says thank you to jogeshwarakundi for this useful post:

    talk2amulya (20th February 2009)

  8. #7
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: custom signals

    here, the signal is declared:
    Qt Code:
    1. class ViewButtonContainer : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. ViewButtonContainer(QWidget *parent);
    7. ~ViewButtonContainer();
    8.  
    9. enum ButtonIndex
    10. {
    11. VISUAL_BROWSING_VIEW,
    12. JOB_SETTINGS_VIEW,
    13. LIST_VIEW
    14. };
    15.  
    16. private:
    17. QPushButton *_visualBrowsingViewButton;
    18. QPushButton *_jobSettingsViewButton;
    19. QPushButton *_listViewButton;
    20.  
    21. private Q_SLOTS:
    22. void handleClicked(bool);
    23.  
    24. signals:
    25. void buttonClicked(int index);
    26. };
    To copy to clipboard, switch view to plain text mode 

    here, the signal containing class is used
    Qt Code:
    1. class VisualBrowsingView : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. VisualBrowsingView(QWidget* parent = 0);
    7. ~VisualBrowsingView();
    8.  
    9. ViewButtonContainer *_buttonContainer;
    To copy to clipboard, switch view to plain text mode 

    above class's object is used here to get the signal and call the slot
    Qt Code:
    1. class StackedWidget : public PScreen, public IJobMgrView
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. StackedWidget(IMS1Shell *parent, IJobMgrControl *control );
    7. ~StackedWidget();
    8.  
    9. VisualBrowsingView *_visualBrowsingWidget;
    10. ListView *_listWidget;
    11.  
    12. private Q_SLOTS:
    13. void showCorrectWidget(int index);
    To copy to clipboard, switch view to plain text mode 

  9. #8
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: custom signals

    jogeshwarakundi already pointed on a problem
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  10. The following user says thank you to spirit for this useful post:

    talk2amulya (20th February 2009)

  11. #9
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: custom signals

    stupid mistake, sorry for wasting ur time guys, this should have been caught by me..copy/paste sux!!

  12. #10
    Join Date
    Dec 2007
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: custom signals

    Quote Originally Posted by spirit View Post
    jogeshwarakundi already pointed on a problem
    interestingly, there is a "thanks" button but then no "you are welcome" button
    Let your work talk for you

Similar Threads

  1. Signals are delayed on X11?
    By Cruz in forum Qt Programming
    Replies: 13
    Last Post: 18th February 2009, 12:59
  2. Custom Widget - First Steps
    By sekatsim in forum Qt Programming
    Replies: 8
    Last Post: 26th June 2008, 17:19
  3. custom signals vs newbie
    By Raccoon29 in forum Newbie
    Replies: 6
    Last Post: 21st April 2008, 16:29
  4. Custom signals?
    By godot in forum Newbie
    Replies: 7
    Last Post: 14th January 2008, 19:13

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.