Two days ago, I saw a younger brother start to use QT to write the Symbian program. I encountered some problems in the middle. After I solved the problem, I checked his development process. I still felt that there were some problems.
Problem description: he created a new QT project in carbide, wrote code here, and debugged it on the Symbian simulator. This is true, but there are two problems:
Problem 1: Debugging in Symbian is too troublesome. It is difficult to debug the simulator in windows.
Question 2: in this way, the PRO project file of the newly created QT project is "specific" and can only be used under Symbian, it cannot be used on other platforms (because some Symbian-specific files, such as RSS files, are added to the Pro file .), This apparently violates the cross-platform principle of QT and limits it to a certain platform.
In view of the above two points, I hate the framework provided by this system! Generally, I solve the problem as follows:
1: Do not use QT for Symbian to create a framework generated by the GUI project. Instead, use QT for Windows to create a new project framework. In the Framework generated under Windows, only the CPP and H program source files are included in the PRO project file. These files are irrelevant to the platform, so they can be fully cross-platform!
The following is the content of a pro file generated by QT for Windows.
Target = qttest
Template = app
Sources + = Main. CPP/
Mainwindow. cpp
Headers + = mainwindow. h
It can be seen that this project file is completely cross-platform, rather than being bound to a certain platform. At the same time, this project can be debugged under windows, and then compiled on carbide to install the mobile phone. You do not need to debug it on the Symbian simulator all the time, the debugging speed is much faster!
2: Someone may ask, how can I import it to carbide and import the above project? In fact, carbide can directly import pro files, but I have never used this method. I always think this is not authentic ~~ Because the carbide is for Symbian, the project file imported on its "Orthodox" should be the bld. inf file unique to Symbian, rather than the pro file. Is there a way to convert the qt pro project file to the Symbian bld. inf project file? The answer is yes. You just need to do the following:
First open command line and CD to the directory where the pro file of your project is located;
Then run the command qmake-platform Symbian-abld to convert the qt pro project file to the Symbian bld. inf project file.
Then, you only need to open carbide and import the bld. inf project file generated above according to the Symbian standard process!
3: Another question may be asked: There are some library files for the project, or the source files are written in Symbian C ++.
But I cannot compile and debug it. What should I do? In fact, this is also easy: in windows, we debug only the QT part of the code, and the Symbian part is certainly not debugging, so to distinguish the two, we should define it in the Pro file, for example:
Win32 {
Headers + =./src/beengine. cpp
}
Symbian {
Sources + =./src/beengine. cpp
}
! Symbian {
UNIX {
Sources + =./src/beengine. cpp
}
}
That is, we can use the platform keyword to identify the platform on which some files will be added to the project and compiled. What is interesting above is the last form. In fact, the official website only uses UNIX as the keyword, but we tried to write it! Symbian. Maybe this is a system bug.
Summary:
1: to create a QT project, we recommend that you use the platform keywords in pro to separate the files on each platform for debugging in windows.
2: to convert a QT project into a VC project, you only need to first use the command line to go to the directory where the PRO project file is located, and then run: qmake-tp vc, in this way, a VC project such as vcproj will be generated, and then you can operate it just like opening a common VC project!
3: to convert a QT project into a Symbian project, you only need to first use the command line to go to the directory where the PRO project file is located, and then run: qmake-platform Symbian-abld, this will generate a bld. A Symbian project like INF, and then operate it like opening a common Symbian project!