首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

QT登录窗口调用主窗口一闪而过有关问题

2012-11-11 
QT登录窗口调用主窗口一闪而过问题原代码:??//如果登录成功??{???index mainForm???mainForm.show()???t

QT登录窗口调用主窗口一闪而过问题

原代码:??//如果登录成功??{
???index mainForm;
???mainForm.show();
???this->hide();
??}主窗口一闪而过??修改为:?//如果登录成功??{
???index mainForm = ?new inde();
???mainForm.show();
???this->hide();
??}程序报错??修改为://如果登录成功??{
???index *mainForm;
???mainForm = new index();
???mainForm->show();
???this->hide();
??}成功显示主窗口。??总结:????index mainForm;
???mainForm.show();?mainForm创建在stack上,生命期是大括号内????index *mainForm;
???mainForm = new index();?mainForm 通过new创建在heap上, 在程序退出时才会被析构

热点排行