读书人

关于Qt初始化的有关问题

发布时间: 2013-02-25 10:23:36 作者: rapoo

关于Qt初始化的问题,求助
我要初始化子控件在主窗口的相对位置,所以必须要创建了这个类之后,显示出来以后才能初始化,不知道Qt有没有类似MFC的InitialDlg这样的函数啊?
[解决办法]
木有,可以写在resizeEvent里。
[解决办法]
可以重载showEvent()
当QWidget被显式显示时,触发这个

void QWidget::showEvent ( QShowEvent * event ) [virtual protected]

This event handler can be reimplemented in a subclass to receive widget show events which are passed in the event parameter.

Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of windows are delivered afterwards.

Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible().
[解决办法]
在构造函数中应该也可以吧

读书人网 >QT开发

热点推荐