当我们把MFC移植到QT时,避免不了会碰到图形文件转换问题,本文通过IconWorkShop处理现有的图形文件,包括Visual C++工具条和光标文件,简单地转换到QT中使用的PNG格式文件。
1.TOOLBAR工具条转换
<RCC>
<qresource prefix="/">
<file>shape/BREAK_LINES.png</file>
<file>shape/CLOSESHAPE.png</file>
<file>shape/COMBINE.png</file>
<file>shape/CONNECT_LINES.png</file>
<file>shape/CONVERT_PATH.png</file>
<file>shape/CONVERT_POLYGON.png</file>
<file>shape/DISMANTLE.png</file>
<file>shape/MERGE_INTERSECT.png</file>
<file>shape/MERGE_MERGE.png</file>
<file>shape/MERGE_SUBSTRACT.png</file>
<file>shape/POLY_DELETEPOINT.png</file>
<file>shape/POLY_INSERTPOINT.png</file>
<file>shape/POLY_MAKECURVE.png</file>
<file>shape/POLY_MAKELINE.png</file>
<file>shape/POLY_RIPUPPOINT.png</file>
</qresource>
</RCC>
QAction *pActCombine = QAction(QIcon(":/shape/COMBINE.png"));
2.光标转换
QPixmap pixmap(":/Cursors/cursor_in.png");
QCursor myCursor(pixmap, 9, 9); // 注意光标热点位置与VC++一致.
setCursor(myCursor);