PDA

View Full Version : Slot never called



Kola73
26th June 2015, 23:46
I have following code:

class MyProxy : public QObject
{
Q_OBJECT
public:
MyProxy() : QObject()
{

}
public slots:
void ButtonPress2()
{
emit SIGNAL(Change());
}
void Changed()
{
QMessageBox::information(0, "Changed","Changed");
}
signals:
void Change();
};

ButtonPress2() is being called from button's clicked() signal, however Changed() slot is never called.

Sorry, I'm absolutely newbie in QT...

ChrisW67
27th June 2015, 08:28
Nothing in your code calls connect() to connect a signal to the Changed() slot or call it directly.
If you want the button to trigger only the Changed() slot then simply connect the button triggered() signal directly to the Changed() slot.

Line 12 might compile but it does not have the intended effect. You want:


emit Change();

Kola73
27th June 2015, 08:48
I called connect(), but error was in emit call, so this works:

emit Change();

Thanks a lot!!!