I placed in a qdialog window a qlable control used to display the countdown, I use qtimer timer in it, and then in the Main window class, which is the Main class in the constructor of the new the qdialog window, in the Main classes of a slot function will show it out, and start the timer, timer starts successfully, but did not enter the timeout () time slot function, is this why? Want to head all quick fry
The main. H
The class Main: public QWidget {
Q_OBJECT
Public:
Explicit Main (QWidget * parent=0);
To the Main ();
Private slots:
Void (A);//slot function
Private:
DlgPro * m_Pro;//information display window
}
DlgPro. H
The class dlgPro: public QDialog {
Q_OBJECT
Public:
Explicit dlgPro (QWidget * parent=0);
~ dlgPro ();
Private:
Qtimer * m_pTmr;
Private slots:
Void onTimer ();//time slot function
}
DlgPro. CPP
DlgPro: : dlgPro (QWidget * parent) : QDialog (parent),
{
M_pTmr=new QTimer (this);
M_pTmr - & gt; SetInterval (1000);
The connect (m_pTmr, SIGNAL (timeout ()), and this, SLOT (onTimer ()));
}
Void dlgPro: : onTimer ()
{
The UI - & gt; Lable - & gt; SetText (" 1111 ");
}
The Main. CPP
Main: : the Main (QWidget * parent) : QWidget (parent),
{
M_Pro=new dlgPro (this);
}
Void Main: : (A)
{
M_Pro - & gt; show();
M_Pro - & gt; M_pTmr - & gt; Start ().
}