How can completely port a qt3 library to qt4?
I have been stumbling thro开发者_如何学JAVAugh some different steps to do this. I ran the qt3to4.exe on the files with compile errors and got though a lot of conversion steps, however now I am getting this error:
1>c:\qt\4.7.0\src\qt3support\widgets\q3toolbar.h(64) : error C2039: 'ToolBarDock' : is not a
member of 'Qt'
and 55 other similar errors. This confuses me since it is in qt's own q3support library. I also saw on a QT help page (http://doc.trolltech.com/4.2/qt-qt3.html) that ToolBarDock is deprecated and Qt::Dock should be used instead.
I haven't found much help on this out there. I'm using the library inside Visual Studio 2008. Any QT/visual studio experts out there?
If this helps, here is the code it is failing on in q3toolbar.h:
Q3ToolBar(const QString &label,
Q3MainWindow *, Qt::ToolBarDock = Qt::DockTop,
bool newLine = false, const char* name=0);
Actually qt34qt4 doesn't do all things right. There are many methods, enums etc, which are not converted. It is more or less simple find-replace tool which replace following instructions from qt\tools\porting\q3porting.xml In many cases there is a replacement definition for a class, but not for a method of this class. In some cases qt3to4 replaces enums and methods in code which doesn't belong to Qt-classes at all. So be carefull. In any case, I would suggest getting a list of all Qt classes in you code, read carefully porting notes (http://doc.qt.nokia.com/4.5/porting4.html) for each class you use. Another issue are return types, qt3to4 doesn't check how the returned value is used. Fortunate qt3to4 makes a good job, so fixing the rest is often a trivial, repetitive task.
If you have to port UIs, take a look at undocumented argument -wrap of uic3.
P.S.: Some figures for your effort estimation, may be usefull: I've ported (got compiled) once 600TLOCs + 150 UIs in 2,5 Months, currently I am porting about 150 TLOCs project and got pretty far in 2 weeks.
I had these errors as well after importing a project into VC++. Adding QT3_SUPPORT to the preprocessor definitions fixed it.
I ended up going a different route on this problem. I found the implementations I needed from the "qt3 library" somewhere else. Just before I found that out, I got some advice from some coworkers here. The consensus was that I'd need to rebuild Qt specifying to include qt3 support. Although I didn't follow through with this, here are some helpful links.
http://www.qtcentre.org/wiki/index.php?title=Qt4_with_Visual_Studio
http://lists.trolltech.com/qt-interest/2006-11/thread00177-0.html
If anyone comes across this and gets through this problem, please post your solution! Thanks.
精彩评论