写个windows下的程序,用的qt,需要访问windows下的HDC字段,记得以前是可以通过
QPixmap * retval;
retval->handle();
获得的,编译了下竟然说没有这个函数,而且竟然也没有提供替代的函数。
察看了下src\gui\images\qpixmap.h
发觉这个函数是提供的,只不过写成这样
#if !defined(Q_WS_WIN) && !defined(Q_WS_MAC)
Qt::HANDLE handle() const;
#endif
而windows环境下是定义了Q_WS_WIN的。
见参考文档
Qt/Windows
When compiling for this platform, the macro Q_WS_WIN is defined.
而在源文件qpixmap.cpp的注释中
/*!
Returns the pixmap's handle to the device context.
\warning This function is Windows-specific; using it is
non-portable.
*/
也既该函数仅适用windows平台。于是我把这些定义改成
#if defined(Q_WS_WIN)
。。。。。
#ndif
重新编译qt,再编译我的程序就可以了.
不知这个是不是qt4的bug
[ 此贴被XChinux在2005-08-02 09:11重新编辑 ]