开发者

how to auto enable a signal on my programme window open

i am using QT4 for my c++ programme i want to enabl开发者_高级运维e 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


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


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜