全部博文(290)
分类: C/C++
2011-01-26 13:53:14
#include
int main(int argc, char *argv[])
{
int QExitCode = 0;
/** 创建一个应用程序对象来管理程序范围内的资源 */
QApplication app( argc, argv );
/** info: widget and MainWindow
a widget is a visual element in a user interface
most application use a QMainWindows or a QDialog as the application Window,
but Qt is so flexible that any Widgets can be a windows .
Qt's widgets emit signals to indicate that a user action or
a change of state has occurred .
*/
QPushButton *button = new QPushButton("Quit");
button->resize( 100, 30 );
/** Qt的 widgets 通过发射信号来指出用户的行为或状态发生改变
一个信号可以和一个函数相连接,称为solt,当single emitted时,
solt 函数自动执行 */
QObject::connect(button,SIGNAL(clicked()),&app ,SLOT(quit()));
/** widgets 被创建后默认为隐藏,因此我们可以在显示它之前对它进行定制,从而避免了闪烁 */
button->show();
/** 再这里,程序将控制权传递给QT,进入事件循环,等待用户输入 */
QExitCode = app.exec();
delete button;
return QExitCode;
}