Qt:Документация 4.3.2/qt3to4

Материал из Wiki.crossplatform.ru

(Различия между версиями)
Перейти к: навигация, поиск
(Новая: {{Qt4.3.2_header}} =qt3to4 - The Qt 3 to 4 Porting Tool<br />= The <tt>qt3to4</tt> tool provides help when moving a project from Qt 3 to Qt 4. It is designed to automate the most tediou...)
 
Строка 2: Строка 2:
=qt3to4 - The Qt 3 to 4 Porting Tool<br />=
=qt3to4 - The Qt 3 to 4 Porting Tool<br />=
 +
<div id="qt3to4"></div>
The <tt>qt3to4</tt> tool provides help when moving a project from Qt 3 to Qt 4. It is designed to automate the most tedious part of the porting effort.
The <tt>qt3to4</tt> tool provides help when moving a project from Qt 3 to Qt 4. It is designed to automate the most tedious part of the porting effort.
See [[Qt:Документация 4.3.2/porting4 | Porting to Qt 4]] and [[Qt:Документация 4.3.2/porting4-designer | Porting .ui Files to Qt 4]] for more information about porting Qt 3 applications to Qt 4.
See [[Qt:Документация 4.3.2/porting4 | Porting to Qt 4]] and [[Qt:Документация 4.3.2/porting4-designer | Porting .ui Files to Qt 4]] for more information about porting Qt 3 applications to Qt 4.
-
 
+
<div id="usage"></div>
==Usage==
==Usage==
<tt>qt3to4</tt> can be run either on individual C++ source or header files, or on an entire project specified by a <tt>qmake</tt> <tt>.pro</tt> file:
<tt>qt3to4</tt> can be run either on individual C++ source or header files, or on an entire project specified by a <tt>qmake</tt> <tt>.pro</tt> file:
Строка 11: Строка 12:
  qt3to4 myapp.pro</source>  
  qt3to4 myapp.pro</source>  
In project mode, <tt>qt3to4</tt> reads the <tt>.pro</tt> file and converts all files specified in it. The tool modifies the files in place. You might want to make a copy of your project before you run the tool.
In project mode, <tt>qt3to4</tt> reads the <tt>.pro</tt> file and converts all files specified in it. The tool modifies the files in place. You might want to make a copy of your project before you run the tool.
-
 
+
<div id="porting-rules"></div>
==Porting Rules==
==Porting Rules==
The Qt porting tool loads its porting rules from an XML file called <tt>q3porting.xml</tt> located in Qt's <tt>tools/porting/src</tt> directory. By editing this file, you can add your own rules or remove some rules.
The Qt porting tool loads its porting rules from an XML file called <tt>q3porting.xml</tt> located in Qt's <tt>tools/porting/src</tt> directory. By editing this file, you can add your own rules or remove some rules.
Строка 20: Строка 21:
*Prefix or rename enum values that have been moved or renamed (e.g&#x2e;, replace <tt>QButton::On</tt> with <tt>QCheckBox::On</tt>) or members of the Qt namespace (e.g&#x2e;, replace <tt>QWidget::red</tt> with <tt>Qt::red</tt>).
*Prefix or rename enum values that have been moved or renamed (e.g&#x2e;, replace <tt>QButton::On</tt> with <tt>QCheckBox::On</tt>) or members of the Qt namespace (e.g&#x2e;, replace <tt>QWidget::red</tt> with <tt>Qt::red</tt>).
*Add <tt>#include</tt> directives that might be needed in Qt 4.
*Add <tt>#include</tt> directives that might be needed in Qt 4.
-
 
+
<div id="location-of-the-qt3porting-xml-file"></div>
===Location of the qt3porting.xml File===
===Location of the qt3porting.xml File===
You can now specify the location of the <tt>qt3porting.xml</tt> file with the <tt>-f</tt> command line option. This is useful if you want to use a modified file with your own rules.
You can now specify the location of the <tt>qt3porting.xml</tt> file with the <tt>-f</tt> command line option. This is useful if you want to use a modified file with your own rules.
-
If you you don't want to maintain a modified <tt>qt3porting.xml</tt> it is possible to create a &quot;patch&quot; file that includes the original file and adds or disables rules. The syntax for this file looks like this:
+
If you you don't want to maintain a modified <tt>qt3porting.xml</tt> it is possible to create a "patch" file that includes the original file and adds or disables rules. The syntax for this file looks like this:
-
<source lang="cpp-qt"> &lt;Rules&gt;
+
<source lang="cpp-qt"> <Rules>
-
   &lt;Include&gt;/path/to/q3porting.xml&lt;/Include&gt;
+
   <Include>/path/to/q3porting.xml</Include>
-
   &lt;item Type=&quot;RenamedHeader&quot; Disable=&quot;True&quot; &gt;
+
   <item Type="RenamedHeader" Disable="True" >
-
     &lt;Qt4&gt;q3sqlselectcursor.h&lt;/Qt4&gt;
+
     <Qt4>q3sqlselectcursor.h</Qt4>
-
     &lt;Qt3&gt;qsqlselectcursor.h&lt;/Qt3&gt;
+
     <Qt3>qsqlselectcursor.h</Qt3>
-
   &lt;/item&gt;
+
   </item>
-
   &lt;item Type=&quot;RenamedHeader&quot; &gt;
+
   <item Type="RenamedHeader" >
-
     &lt;Qt4&gt;newclass.h&lt;/Qt4&gt;
+
     <Qt4>newclass.h</Qt4>
-
     &lt;Qt3&gt;oldclass.h&lt;/Qt3&gt;
+
     <Qt3>oldclass.h</Qt3>
-
   &lt;/item&gt;
+
   </item>
-
  &lt;/Rules&gt;</source>  
+
  </Rules></source> <div id="logging"></div>
==Logging==
==Logging==
The porting tool logs all changes to a file called <tt>portinglog.txt</tt> in the current directory. This file lists all changes made to the source files.
The porting tool logs all changes to a file called <tt>portinglog.txt</tt> in the current directory. This file lists all changes made to the source files.
-
 
+
<div id="advanced-usage"></div>
==Advanced Usage==
==Advanced Usage==
When porting, <tt>qt3to4</tt> parses the source files and ports the contents according to the C++ language rules. This C++ parsing step can be disabled with the <tt>-disableCppParsing</tt> option.
When porting, <tt>qt3to4</tt> parses the source files and ports the contents according to the C++ language rules. This C++ parsing step can be disabled with the <tt>-disableCppParsing</tt> option.
Строка 51: Строка 52:
To see which headers that are not found, use the <tt>-missingFileWarnings</tt> option.
To see which headers that are not found, use the <tt>-missingFileWarnings</tt> option.
-
 
+
<div id="limitations"></div>
==Limitations==
==Limitations==
In some cases, you might get compiler errors because of identifiers in the global namespace (e.g&#x2e;, <tt>CTRL</tt>). Adding
In some cases, you might get compiler errors because of identifiers in the global namespace (e.g&#x2e;, <tt>CTRL</tt>). Adding
<source lang="cpp-qt">    using namespace Qt;</source>  
<source lang="cpp-qt">    using namespace Qt;</source>  
at the beginning of the source file that contains the indentifier solves the problem.
at the beginning of the source file that contains the indentifier solves the problem.
-
 
+
<div id="legal-notices"></div>
==Legal Notices==
==Legal Notices==
Some source code in <tt>qt3to4</tt> is licensed under specific highly permissive licenses from the original authors. Trolltech gratefully acknowledges these contributions to <tt>qt3to4</tt> and all uses of <tt>qt3to4</tt> should also acknowledge these contributions and quote the following license statements in an appendix to the documentation.
Some source code in <tt>qt3to4</tt> is licensed under specific highly permissive licenses from the original authors. Trolltech gratefully acknowledges these contributions to <tt>qt3to4</tt> and all uses of <tt>qt3to4</tt> should also acknowledge these contributions and quote the following license statements in an appendix to the documentation.
*[[Qt:Документация 4.3.2/qt3to4-treewalker | Contributions to the Following qt3to4 Files: treewalker.h, treedump.cpp, treedump.h, treewalker.cpp]]
*[[Qt:Документация 4.3.2/qt3to4-treewalker | Contributions to the Following qt3to4 Files: treewalker.h, treedump.cpp, treedump.h, treewalker.cpp]]
-
 
{{Qt4.3.2_footer}}
{{Qt4.3.2_footer}}

Текущая версия на 10:35, 6 ноября 2008

40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] qt3to4 - The Qt 3 to 4 Porting Tool

The qt3to4 tool provides help when moving a project from Qt 3 to Qt 4. It is designed to automate the most tedious part of the porting effort.

See Porting to Qt 4 and Porting .ui Files to Qt 4 for more information about porting Qt 3 applications to Qt 4.

[править] Usage

qt3to4 can be run either on individual C++ source or header files, or on an entire project specified by a qmake .pro file:

 qt3to4 myfile.cpp
 qt3to4 myapp.pro

In project mode, qt3to4 reads the .pro file and converts all files specified in it. The tool modifies the files in place. You might want to make a copy of your project before you run the tool.

[править] Porting Rules

The Qt porting tool loads its porting rules from an XML file called q3porting.xml located in Qt's tools/porting/src directory. By editing this file, you can add your own rules or remove some rules.

The standard q3porting.xml file specifies the following conversions:

  • Rename classes that are now part of the Qt 3 support library (e.g., replace QFileDialog with Q3FileDialog).
  • Prefix or rename enum values that have been moved or renamed (e.g., replace QButton::On with QCheckBox::On) or members of the Qt namespace (e.g., replace QWidget::red with Qt::red).
  • Add #include directives that might be needed in Qt 4.

[править] Location of the qt3porting.xml File

You can now specify the location of the qt3porting.xml file with the -f command line option. This is useful if you want to use a modified file with your own rules.

If you you don't want to maintain a modified qt3porting.xml it is possible to create a "patch" file that includes the original file and adds or disables rules. The syntax for this file looks like this:

 <Rules>
   <Include>/path/to/q3porting.xml</Include>
 
   <item Type="RenamedHeader" Disable="True" >
     <Qt4>q3sqlselectcursor.h</Qt4>
     <Qt3>qsqlselectcursor.h</Qt3>
   </item>
 
   <item Type="RenamedHeader" >
     <Qt4>newclass.h</Qt4>
     <Qt3>oldclass.h</Qt3>
   </item>
 </Rules>

[править] Logging

The porting tool logs all changes to a file called portinglog.txt in the current directory. This file lists all changes made to the source files.

[править] Advanced Usage

When porting, qt3to4 parses the source files and ports the contents according to the C++ language rules. This C++ parsing step can be disabled with the -disableCppParsing option.

If C++ parsing is enabled, qt3to4 must be able to locate the headers included from the source files. Necessary headers include the public Qt headers and any headers that declares names that may conflict with names in the public Qt headers. The standard C++ headers and system headers are usually not needed.

You can tell qt3to4 where to look for headers by using the -I command-line option. Qt 3.3 header information is built in, so it is normaly not necessary to specify the location of the Qt headers. If you are porting from a different version of Qt 3, you may want to disable the built-in headers with -disableBuiltInQt3Headers, and then add the path to the actual headers with the -I option.

When porting a project, qt3to4 will read the INCLUDEPATH and DEPENDPATH variables from the .pro file and add the paths specified here to the list of include search directories.

To see which headers that are not found, use the -missingFileWarnings option.

[править] Limitations

In some cases, you might get compiler errors because of identifiers in the global namespace (e.g., CTRL). Adding

     using namespace Qt;

at the beginning of the source file that contains the indentifier solves the problem.

[править] Legal Notices

Some source code in qt3to4 is licensed under specific highly permissive licenses from the original authors. Trolltech gratefully acknowledges these contributions to qt3to4 and all uses of qt3to4 should also acknowledge these contributions and quote the following license statements in an appendix to the documentation.


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2