Can we emit a signal from a public slot

Viewed 1037
class MyMainWindow:public QMainWindow {
    public:
        MyWindow* myWindow() { return myWindow ;}
    private:
        MyWindow* myWindow;
};

class MyWindow:public Qobject {
    private slot:
        void mySlot();
};

class MyWindow2: class QWidget {
    public slot:
        void refreshClick();
    signals:
        signal1();
};

MyWindow2::MyWindow2(QMainWindow* parent) {
    QPushButton* refresh;
    QObject::connect(refresh,SIGNAL(clicked()), this, SLOT(refreshClicked()));

    if(parent) {
         QObject::connect(this,SIGNAL(signal1),parent->myWindow(),SLOT(mySlot));
    }

}

void MyWindow2::refreshClicked(){
    emit signal1();
}

I want to know if it is legal to emit signal1 from slot refreshClicked and also are there any cons of emitting a signal from within a slot

1 Answers
Related