简体   繁体   English

如何将qt3库完全移植到qt4?

[英]How can completely port a qt3 library to qt4?

I have been stumbling through 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. 我在带有编译错误的文件上运行qt3to4.exe并获得了很多转换步骤,但是现在我收到了这个错误: 1>c:\\qt\\4.7.0\\src\\qt3support\\widgets\\q3toolbar.h(64) : error C2039: 'ToolBarDock' : is not a member of 'Qt'还有55个其他类似的错误。 This confuses me since it is in qt's own q3support library. 这让我很困惑,因为它在qt自己的q3support库中。 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. 我还在QT帮助页面(http://doc.trolltech.com/4.2/qt-qt3.html)上看到了不推荐使用ToolBarDock而应该使用Qt :: Dock。 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? 我正在使用Visual Studio 2008中的库。那里有任何QT / visual studio专家吗?

If this helps, here is the code it is failing on in q3toolbar.h: 如果这有帮助,这里是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. 实际上qt34qt4没有做好所有事情。 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. 它或多或少是简单的查找替换工具,它取代了qt \\ tools \\ porting \\ q3porting.xml中的以下指令。在许多情况下,有一个类的替换定义,但不适用于此类的方法。 In some cases qt3to4 replaces enums and methods in code which doesn't belong to Qt-classes at all. 在某些情况下,qt3to4替换了完全不属于Qt类的代码中的枚举和方法。 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. 在任何情况下,我建议您在代码中获取所有Qt类的列表,仔细阅读您使用的每个类的移植说明(http://doc.qt.nokia.com/4.5/porting4.html)。 Another issue are return types, qt3to4 doesn't check how the returned value is used. 另一个问题是返回类型,qt3to4不检查返回值的使用方式。 Fortunate qt3to4 makes a good job, so fixing the rest is often a trivial, repetitive task. 幸运的qt3to4做得很好,所以修复其余部分往往是一项微不足道的重复性任务。

If you have to port UIs, take a look at undocumented argument -wrap of uic3. 如果你需要移植UI,请查看uic3的未记录的参数-wrap。

PS: 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. PS:你的努力估计的一些数字可能是有用的:我已经在2,5个月内移植(编译)一次600TLOCs + 150个UI,目前我正在移植大约150个TLOC项目并在2周内相当远。

I had these errors as well after importing a project into VC++. 将项目导入VC ++后,我也遇到了这些错误。 Adding QT3_SUPPORT to the preprocessor definitions fixed it. 将QT3_SUPPORT添加到预处理器定义修复它。

I ended up going a different route on this problem. 我最终在这个问题上采取了不同的路线。 I found the implementations I needed from the "qt3 library" somewhere else. 我从其他地方的“qt3库”中找到了我需要的实现。 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. 共识是我需要重建Qt,指定包括qt3支持。 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://www.qtcentre.org/wiki/index.php?title=Qt4_with_Visual_Studio

http://lists.trolltech.com/qt-interest/2006-11/thread00177-0.html 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. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM