商業版源代碼包:qt-win-commercial-src-4.2.2.zip,由於涉及盜版,不宜公開下載。
1、解壓
將源碼包解壓到c:/下,重命令文件夾爲qt4。
2、license文件
在你的當前用戶文件夾下(如:C:/Documents and Settings/Administrator)建立文件.qt-license.
編輯之,貼入以下內容(其中的LicenseKeyExt不方便在此提供,大家網上應該可以搜到)
[code]==================================
LicenseKeyExt="xxxx-xxx-xxx-xxx-xxxx-xxxx-xxxx"
LicenseId="0"
Licensee="Any Name"
ProductType="qt-enterprise"
LicenseType="Commercical"
ExpiriDate=3002-09-21
================================== [/code]
3、環境變量
(不知道是不是我的VS太笨,居然沒有設置環境變量,只好自己設了)
打開VS目錄下common7/tools目錄下的vsvars32.bat文件,然後右鍵我的電腦->屬性->高級->環境變量,參考vsvars32.bat文件來設置環境變量。
以下是我修改後的環境變量:
[code]
@SET VSINSTALLDIR=C:/Program Files/Microsoft Visual Studio 8
@SET VCINSTALLDIR=C:/Program Files/Microsoft Visual Studio 8/VC
@SET FrameworkDir=C:/WINDOWS/Microsoft.NET/Framework
@SET FrameworkVersion=v2.0.50727
@SET FrameworkSDKDir=C:/Program Files/Microsoft Visual Studio 8/SDK/v2.0
@set DevEnvDir=C:/Program Files/Microsoft Visual Studio 8/Common7/IDE
@set PATH=C:/Program Files/Microsoft Visual Studio 8/Common7/IDE;C:/Program Files/Microsoft Visual Studio 8/VC/BIN;C:/Program Files/Microsoft Visual Studio 8/Common7/Tools;C:/Program Files/Microsoft Visual Studio 8/Common7/Tools/bin;C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/bin;C:/Program Files/Microsoft Visual Studio 8/SDK/v2.0/bin;C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727;C:/Program Files/Microsoft Visual Studio 8/VC/VCPackages;c:/qt4
[b]@rem 注意這裏要有qt4的路徑,另外注意,別忘了把你原來的Path變量加進來[/b]
@set INCLUDE=C:/Program Files/Microsoft Visual Studio 8/VC/ATLMFC/INCLUDE;C:/Program Files/Microsoft Visual Studio 8/VC/INCLUDE;C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/include
@set LIB=C:/Program Files/Microsoft Visual Studio 8/VC/ATLMFC/LIB;C:/Program Files/Microsoft Visual Studio 8/VC/LIB;C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/lib;C:/Program Files/Microsoft Visual Studio 8/SDK/v2.0/lib
@set LIBPATH=C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727;C:/Program Files/Microsoft Visual Studio 8/VC/ATLMFC/LIB
[/code]
4、修改源代碼
由於vs2005sp1引入了一個BUG,導致源代碼無法順利編譯。請參考http://support.microsoft.com/kb/928957
修改C:/qt4/src/corelib/tools目錄下有問題的文件qhash.h和qmap.h
以下以qhash.h爲例
將
[code]class QMultiHash : public QHash<Key, T>
{
public:
QMultiHash() {}
QMultiHash(const QHash<Key, T> &other) : QHash<Key, T>(other) {}
inline typename QHash<Key, T>::iterator replace(const Key &key, const T &value); // 有問題的代碼
inline typename QHash<Key, T>::iterator insert(const Key &key, const T &value); //有問題的代碼
inline QMultiHash &operator+=(const QMultiHash &other)
{ unite(other); return *this; }
inline QMultiHash operator+(const QMultiHash &other) const
{ QMultiHash result = *this; result += other; return result; }
private:
T &operator[](const Key &key);
const T operator[](const Key &key) const;
};
template <class Key, class T>
Q_INLINE_TEMPLATE Q_TYPENAME QHash<Key, T>::iterator QMultiHash<Key, T>::replace(const Key &akey, const T &avalue) // 這行也需要修改
{ return QHash<Key, T>::insert(akey, avalue); }
template <class Key, class T>
Q_INLINE_TEMPLATE Q_TYPENAME QHash<Key, T>::iterator QMultiHash<Key, T>::insert(const Key &akey, const T &avalue) // 這行也需要修改
{ return QHash<Key, T>::insertMulti(akey, avalue); }[/code]
修改爲:
[code]class QMultiHash : public QHash<Key, T>
{
public:
QMultiHash() {}
QMultiHash(const QHash<Key, T> &other) : QHash<Key, T>(other) {}
typedef QHash<Key, T>::iterator QHash_iterator; // 增加一個typedef
inline typename QHash_iterator replace(const Key &key, const T &value); // 在整個類中都使用這個typedef
inline typename QHash_iterator insert(const Key &key, const T &value); // 在整個類中都使用這個typedef
inline QMultiHash &operator+=(const QMultiHash &other)
{ unite(other); return *this; }
inline QMultiHash operator+(const QMultiHash &other) const
{ QMultiHash result = *this; result += other; return result; }
private:
T &operator[](const Key &key);
const T operator[](const Key &key) const;
};
template <class Key, class T>
Q_INLINE_TEMPLATE Q_TYPENAME QMultiHash<Key, T>::QHash_iterator QMultiHash<Key, T>::replace(const Key &akey, const T &avalue) // 在整個類中都使用這個typedef
{ return QHash<Key, T>::insert(akey, avalue); }
template <class Key, class T>
Q_INLINE_TEMPLATE Q_TYPENAME QMultiHash<Key, T>::QHash_iterator QMultiHash<Key, T>::insert(const Key &akey, const T &avalue)// 在整個類中都使用這個typedef
{ return QHash<Key, T>::insertMulti(akey, avalue); }[/code]
OK,大功告成
configure
nmake
祝你成功!
LicenseID="4444"
Licensee="StarDancer"
LicenseKeyExt=FGKX-RM5-F4M-2CX-3P5X-HGM8X-2B52