我要初始化子控件在主窗口的相对位置,所以必须要创建了这个类之后,显示出来以后才能初始化,不知道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().
------解决方案--------------------
在构造函数中应该也可以吧