View Full Version : custom signals
talk2amulya
20th February 2009, 08:17
do we have to declare smth extra to use custom signals(our own defined signals)?
spirit
20th February 2009, 08:37
what do you mean?:confused: all what you need it add Q_OBJECT and emit for emitting a signal.
jogeshwarakundi
20th February 2009, 08:41
and if you wish to use your own data type as parameter, register it with the metatype system
talk2amulya
20th February 2009, 08:44
i declared the following signal in a class
signals:
void buttonClicked(int index);
and used the signal in a different class, to connect to a slot
bool isConnect = connect(_visualBrowsingWidget->_buttonContainer, SIGNAL(buttonClicked(int index)), this, SLOT(showCorrectWidget(int index)));
but signal doesnt connect, saying:
Object::connect: No such signal ViewButtonContainer::buttonClicked(int index)
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?
spirit
20th February 2009, 08:46
show us declaration of ViewButtonContainer.
jogeshwarakundi
20th February 2009, 08:50
inside the connect statement, you should not specify the parameter name....
connect(...SIGNAL(sometingHappened(int))....);
talk2amulya
20th February 2009, 08:52
here, the signal is declared:
class ViewButtonContainer : public QWidget
{
Q_OBJECT
public:
ViewButtonContainer(QWidget *parent);
~ViewButtonContainer();
enum ButtonIndex
{
VISUAL_BROWSING_VIEW,
JOB_SETTINGS_VIEW,
LIST_VIEW
};
private:
QPushButton *_visualBrowsingViewButton;
QPushButton *_jobSettingsViewButton;
QPushButton *_listViewButton;
private Q_SLOTS:
void handleClicked(bool);
signals:
void buttonClicked(int index);
};
here, the signal containing class is used
class VisualBrowsingView : public QWidget
{
Q_OBJECT
public:
VisualBrowsingView(QWidget* parent = 0);
~VisualBrowsingView();
ViewButtonContainer *_buttonContainer;
above class's object is used here to get the signal and call the slot
class StackedWidget : public PScreen, public IJobMgrView
{
Q_OBJECT
public:
StackedWidget(IMS1Shell *parent, IJobMgrControl *control );
~StackedWidget();
VisualBrowsingView *_visualBrowsingWidget;
ListView *_listWidget;
private Q_SLOTS:
void showCorrectWidget(int index);
spirit
20th February 2009, 08:53
jogeshwarakundi already pointed on a problem :)
talk2amulya
20th February 2009, 08:54
stupid mistake, sorry for wasting ur time guys, this should have been caught by me..copy/paste sux!!
jogeshwarakundi
20th February 2009, 08:55
jogeshwarakundi already pointed on a problem :)
interestingly, there is a "thanks" button but then no "you are welcome" button :D
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.