Build a QT 5.3.1 for Windows Phone 8 development environment
QT has supported the development of Android and iOS, and I have personally tried to develop on Android and iOS, in which the research of Android is deeper and the first independent game "take Medicine" has been produced. In the release of QT's new version 5.3, the official announcement supports the development of WindowsPhone 8/8.1. After two months, I also actively try to see how the latest QT 5.3.1 builds the WP8 development environment.
original article, against undeclared references. Original Blog address:http://blog.csdn.net/gamesdev/article/details/38568903
1. Hardware Requirements
The first is the hardware. The advantage of developing windowsrt/windows phone is that my notebook is a 64-bit system, the CPU is the Intel Core i7-4700mq four-core processor, the memory capacity is 4G, and runs the Windows 8.1 operating system. Computers that are typically a few years ago may not be capable of such development, because the CPU must support Hyper-V technology to support the development of Windows Phone. This is Microsoft's proposed virtualization technology, which is equivalent to running Windows Phone virtual machines under Windows 8.1. For Hyper-V requirements, I checked that the CPU must be 64-bit, and that it supports hardware self-protection (DEP) functionality, and that it has been started, with a minimum memory of 2G. My computer was so easy to meet the requirements that I was able to develop Windows Phone successfully.
2. Software Requirements
The first requirement is to install the windows8/8.1 operating system. What can Windows 7 do? Read the online post, may not ...
Secondly, I read the QT forwinrt theme of the QT Help document and learned that to support the development of Windows Phone, you need to install the corresponding visual Studio. For Windows Phone 8/8.1 that we care about, you need to install visual Studio for Windows Phone. But now is the time, I can't wait to use the latest version of Visual Studio. So to this site, get ed2k resources, open the Thunderbolt start high-speed download the latest version of Visual Studio 14. Visual Studio14 has a choice of components at the time of installation, so remember to choose the Windows Phone SDK.
Finally QT is essential, download the latest "Qt5.3.1 for Windows RT 32-bit (647 MB)" in qt-project.org, then unzip to the appropriate location on the line.
The installation order is VisualStudio 14→QT 5.3.1 for Windows RT. The QT Creator is then opened with Qt.
3. Test the first program
First Open Qt Creator, which is the IDE attached to the Qt5.3.1. Create a new QML project and set up the build suite as follows:
The generated code looks like this, and here's a little bit of a change:
I'll start with the desktop suite first, and the results are as follows:
Everything is fine.
4. Start porting Windows Phone 8
Next I'll try porting The example program to Windows Phone 8. As shown in the first picture, we can select the physical machine Kit and the simulator (Emulator) kit. For those who do not have physical machines, they can only choose Emulator. When we follow normal steps, build, and then run, the Windows Phone virtual machine pops up, and everything looks fine:
But there's a hole here. After a while the program starts to become blank:
The following will also pop up
Qt.winrtrunner: "E:/qtproject/build-testquickforwinphone8-qt_5_3_for_windows_phone_8_x86_msvc2012_32bit_ Emulator-release/release/appxmanifest.xml "does not exist.
Qt.winrtrunner: "E:/qtproject/build-testquickforwinphone8-qt_5_3_for_windows_phone_8_x86_msvc2012_32bit_ Emulator-release/release/appxmanifest.xml "does not exist.
Such a scarlet letter. This problem is not affected by the following understanding. Just how can we show the program?
5, interface, you come back soon
Qt for WinRT This article says that when we test, QT will provide a gadget called Qd3dservice. It can instantly compile and present shaders to the application. Because of OpenGL, which supports QT rendering, after encountering Microsoft's mobile phone, it has to "Direct3D" and "see" the Windows Phone 8 phone in a coat of clothing. You need to convert the shader code from OpenGL ES2.0 to D3D shader through a project in Google Code, angle. The interface could not be displayed just now because shaders that are dependent on the interface are not loaded.
The workaround is simple enough to run Qtd3dservice with no parameters in the bin directory of the QTSDK. And then open the program we compiled:
This is a little bit better, at least we see the interface, but a lot of blocks and let us worry about. This is another pit . So how can we see the text?
6, text, you come back soon
Looking at the directory structure of the QT 5.3.1for Windows phone, one notable difference is that there is a directory named "Font" in both the bin and Lib folders, which is the font that is associated with the interface display. These fonts are included when packaged by default. Wait, we just ran the program like this, but we didn't pack it up. So how do you package it? It depends on the VS14 we just installed. First locate $${yourprojectdirctory}, open a command prompt, enter:
$${QTDIR}/5.3/WINPHONE_X86/BIN/QMAKE-TP Vcyourproject.pro "CONFIG+=WINDEPLOYQT"
Here's what I do:
After running, found that Uuidgen was not found. This is another pit. At first I tried to find Uuidgen.exe, even to download a uuidgen.exe on the internet, and placed in the c:/windows/system32, the results have not worked! So that's another pit. However, this error does not affect this step, and some of the necessary QT and VS project files can be generated smoothly.
This opens the generated vcxproj file with VS14. As shown below:
At this point, click Deploy and try. Result Error!
C:\Program Files (x86) \msbuild\microsoft\windowsphone\v8.0\microsoft.phone.packaging.targets (637,9): Error:the ' ProductID ' attribute is invalid-the value ' {} ' was invalidaccording to its datatype ' http://WPCommontypes:ST_Guid '-the Patternconstraint failed.
This is the place where the Uuidgen deceptive . The package cannot be deployed because ProductID cannot be generated.
The urgency of a thing is the ability to find a way to produce a UUID. There are several ways to do this.
(1) vs has a tool called Guidgen.exe, and Uuidgen only one letter. It can be used to generate UUID;
(2) To download Uuidgen.exe on the Internet, which is the old thing of the 1996 Microsoft, but still can produce UUID under the command character;
(3) Everyone has a Chrome browser to teach you how to use Chrome to create UUID. In fact any JS interpreter environment can be, including QML Engine. Open Chrome,ctrl + Shift + J, open the JS console, and enter the following JS code:
function GetGuid () {function _p8 (s) {var p = (Math.random (). toString () + "000000000"). substr (2,8); return s? "-" + p.substr (0,4) + "-" + P.SUBSTR (bis): p;} return _p8 () + _P8 (true) + _P8 (true) + _P8 ();} GetGuid ();
Enter, you will be able to produce a valid UUID. The UUID I produce here is:
684cebbf-bb4a-857b-9a1e-746feb967cd3
What we need to do is to go into the project directory, edit the Wmappmanifest.xml, find the ProductID field, put the UUID we generated in the curly braces, and save it.
Then go to VS14, click Deploy, and then CTRL + F5 run at full speed. Remember to run Qtd3dservice before running. The results of the operation are as follows:
Done! After two days of trying and asking questions, I was able to successfully run the QT program on the Windows Phone. For more development questions on Windows Phone, I'll look into it sometime.
7. Summary
Here's a little summary:
1. The suffix of the Windows phone app installation package is a. xap file that can be opened with the compression decompression tool such as 7-zip, opened and found to be similar to the directory structure of the Android APK installation package.
2, as described above, with the development of QT WindowsPhone 8 There are many pits, again such as this example, want to click on the upper left corner of the File menu, is not sensitive, sometimes the exit option will monopolize the entire screen, it appears that this screen is very empty; Some important QT modules, such as the Enginio I desperately need, have not been transplanted. So developing a Windows Phone 8 app is still experimental, and hopefully it will do better in QT 5.4.
3. If you do not want to compile the shader online every time you start Qtd3dservice, you can use "Qtd3dservice--list-binary--qrc--device 0--app { 684CEBBF-BB4A-857B-9A1E-746FEB967CD3}--OUTPUT/PATH/TO/PROJECT/SHADERS.QRC "To generate shader resources, and then modify the Pro file, add this line:" resources+= SHADERS.QRC ", and finally recompile the package.
4, in fact, Qtd3dservice is only a preliminary feasible approach, when considering the Windows policy does not allow JIT compilation. As a result of the QT team discussion I saw on Jira, Qtd3dservice will be removed in Qt5.4. Because (1) Windows 8.1 supports the compilation of device online (JIT) shaders, (2) Qtd3dservice is only an experimental solution that does not need to be maintained in the future, and (3) can be applied to shaders using the cache method taken by Scene-graph. (See here)
5. Even if Hyper-V technology is used, the experience of WindowsPhone 8 on the simulator is still less than the real machine. I used to successfully run Digia's QT application quick forcast in Suning appliance city using the Nokia Lumia 525. If you have the conditions, you should buy a real machine for the development test.