• 7802阅读
  • 6回复

QT4 中怎样得到主窗口? [复制链接]

上一主题 下一主题
离线cresthong
 

只看楼主 倒序阅读 楼主  发表于: 2008-06-02
— 本帖被 XChinux 执行加亮操作(2008-06-03) —
在QT3中有得到主窗口的函数,在QT4中好像没用,有什么好办法?
[ 此贴被cresthong在2008-06-03 13:09重新编辑 ]
离线081620
只看该作者 1楼 发表于: 2008-06-02
this->parentWidget()
离线benwhite

只看该作者 2楼 发表于: 2008-06-02
QT4.3.4

QWidget * QWidget::parentWidget () const
Returns the parent of this widget, or 0 if it does not have any parent widget.
是指这个函数吗?
离线benwhite

只看该作者 3楼 发表于: 2008-06-02
居然和1楼的 同时发表回复
太巧合了!!!
离线cresthong

只看该作者 4楼 发表于: 2008-06-03
引用第1楼081620于2008-06-02 23:04发表的  :
this->parentWidget()

如果this不QWidget的子类呢?
离线fengniu9
只看该作者 5楼 发表于: 2008-06-04
在生成MainWindow的构造函数中保留this 指针,如:
QWiget *qMainwindow=this;
再把qMainwindow设成全局变量,就可以在任何地方访问到MainWindow了.
离线93804371
只看该作者 6楼 发表于: 2012-06-04
快速回复
限100 字节
 
上一个 下一个