[static] Qt::HANDLE QThread::currentThreadId()我人工翻译下:
Returns the thread handle of the currently executing thread.
Warning: The handle returned by this function is used for internal purposes and should not be used in any application code.
Warning: On Windows, the returned value is a pseudo-handle for the current thread. It can't be used for numerical comparison. i.e., this function returns the DWORD (Windows-Thread ID) returned by the Win32 function getCurrentThreadId(), not the HANDLE (Windows-Thread HANDLE) returned by the Win32 function getCurrentThread().
[static] Qt::HANDLE QThread::currentThreadId()
返回当前执行线程的句柄。
警告:此函数返回的句柄是作为(Qt)内部使用的,不应出现在任何应用代码中。
警告:在Window中,返回值为当前线程的pseudo-handle对象。它无法用于数值对比。也就是说,此函数的返回值为Win32函数getCurrentThreadId()返回的Windows-Thread ID(DWORD类型),而并非Win32函数getCurrentThread()返回的Windows-Thread HANDLE(HANDLE类型)
WId QWidget::winId() constReturns 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 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.
此接口为了可移植性,但如果你使用了它,这意味着你可能准备做一些无法移植的操作。当心。正如使用currentThreadId()获取线程id,来进行显示输出一样,在不同平台,我们就得编写不同的代码分支来处理这个Qt::HANDLE,破坏了移植性的同时,也破坏了代码的美观程度,提高了维护成本。
欢迎光临 firemail (http://firemail.wang:8088/) | Powered by Discuz! X3 |