QT5 与QT 4 QT3 区别

QT5中显示窗口 没必要再setmainwidget了,直接删掉,直接show出你的窗口就行了:

QApplication a(argc, argv);
QPushButton hello( "Hello world!", 0 );

hello.resize( 100, 30 );

//a.setMainWidget( &hello );//删除,setMainWidget不是QApplication的成员

hello.show();

return a.exec();

而QT3中:

QApplication a(argc, argv);
QPushButton hello( "Hello world!", 0 );

hello.resize( 100, 30 );

a.setMainWidget( &hello );//需要设置

hello.show();

return a.exec();

猜你喜欢

转载自blog.csdn.net/qq363099233/article/details/80908950