• 12445阅读
  • 2回复

[提问]获取QT窗口句柄 [复制链接]

上一主题 下一主题
离线realmao
 
只看楼主 倒序阅读 楼主  发表于: 2011-02-10
刚刚接触QT,不知道是不是像MFC那样。。。
程序的mainwindow是主窗口类,设了一个指针ui
有一个继承Qwidget的类负责画图
我想新建一个.h在里面写一个类,能够直接通过该类在窗口上画图
请问如何获取QmainWindow的句柄呢??
新手,见谅。。。

离线simeitech
只看该作者 1楼 发表于: 2012-06-23
查这个问题查了N天了,烦死了。
离线xiongyu

只看该作者 2楼 发表于: 2012-06-23
WId QWidget::winId () const

Returns the window system identifier of the widget.

Portable in principle, but if you use it you are probably about to do something non-portable. Be careful.

If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle.

On Mac OS X, the type returned depends on which framework Qt was linked against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt is using Cocoa, {WId} is a pointer to an NSView.

This value may change at run-time. An event with type QEvent::WinIdChange will be sent to the widget following a change in window system identifier.
为自己而已努力吧... 我的博客 http://xycode.org
快速回复
限100 字节
 
上一个 下一个