Peeyush
Peeyush

Reputation: 4828

how to auto enable a signal on my programme window open

i am using QT4 for my c++ programme i want to enable a SIGNAL automatically when my window is open so please tell me how do i enable a SIGNAL when my programme window open.

i am new to QT so please give a detail description.

Thanks

Upvotes: 2

Views: 474

Answers (2)

jopa
jopa

Reputation: 1139

Overwrite QWidget::showEvent() (see QT documentation)

Upvotes: 3

mosg
mosg

Reputation: 12381

You may rewrite public function show in you class, for example:

mainwindow.h

class MainWindow : public QMainWindow {
    Q_OBJECT;
public:
    MainWindow();

    void myShow() {
        activateWindow();
        show();
        emit mySignalFunc();
    }
signals:
    void mySignalFunc() {
        qDebug() << "Here is my signal!!!";
    };
};

main.cpp in main() function:

MainWindow wnd;
wnd.myShow();

Good luck!

Upvotes: 1

Related Questions