Let Qt for Windows Phone 8.1 run on a real machine

Source: Internet
Author: User





Let Qt for Windows Phone 8.1 run on a real machine






Some of the previous posts are intended for this article, and the ultimate goal is to use the QT framework to create programs that run on Windows Phone 8.1 real-world machines. Because Qt for WP8 this piece is imperfect, in addition I just entered this field, so the research speed is a bit slow. Asked the maintainer of the QT project on the internet, plus a little research, a little bit about the development of QT for Windows Phone 8.



original article, against undeclared references. Original Blog address:http://blog.csdn.net/gamesdev/article/details/38967749



Using QT to develop a Windows Phone 8 app and be able to run on the real machine, on the basis of the previous article, you need to register the developer account and unlock the phone so that you can successfully develop.



The software that needs to be mated here is QTSDK for Windows runtime, QT Creator3.1.2 (bundled in Qt for Windows Runtime) and visual Studio 2012 or later (included).


Let the widgets program run on a Windows Phone 8.1 real Machine


Let's start with a simple widgets program. Open Qtcreator and create a widgets program. Then enter the code in the main function:




#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QBoxLayout>

int main( int argc, char** argv )
{
    QApplication app( argc, argv );

    QLabel* pLabel = new QLabel( QObject::tr( "Hello Windows Phone 8" ) );

    QHBoxLayout* pHLayout = new QHBoxLayout;
    pHLayout->addStretch( );
    pHLayout->addWidget( pLabel );
    pHLayout->addStretch( );

    QVBoxLayout* pVLayout = new QVBoxLayout;
    pVLayout->addLayout( pHLayout );

    QWidget widget;
    widget.setStyleSheet( "background-color: #FF0000FF" );
    widget.setLayout( pVLayout );
    widget.showFullScreen( );

    return app.exec( );
}


Using the desktop suite, running, is the result:






Good. Here's how to migrate to the Windows Phone 8.1 platform. Select the kit for Windows Phone 8, and then add the custom build steps in the "Build" column, such as.






Where the command is qmake, the parameter is-TP vc%{sourcedir}/%{currentproject:name}.pro "CONFIG+=WINDEPLOYQT", the working directory is%{builddir}, The goal is to build the VisualStudio project and let vs continue to build.



Then locate the vcxproj file in%{builddir} and open it with VisualStudio. Choose Deploy to deploy it on your phone and run it from your phone, and you're done. It's so simple.





Let the quick program run on the real machine


Next, let's describe how the Qtquick program runs on a Windows Phone 8.1 real machine.


1. Similarly, set up a QT Quick project:





Let's run the desktop kit first, and that's the effect:





2. (optional) Set the font in the pro file.


Qtcreator The default font fonts is not set, all fonts will be packaged in the XAP file, so that the XAP package file at least 10M, reduce unnecessary fonts, you can reduce the package size to about 8M. Here's how I set up fonts:



Fonts=$$[qt_install_bins]/fonts/dejavusans.ttf



We can find all the available fonts in $$[qt_install_bins]/fonts, of course you can add the fonts you like, if not set, these fonts will be packaged. So set fonts as a valid font, but if set fonts=, will cause no fonts available, run the program will appear a block.


3. Add a custom processing step for the project.


Here the method is the same as building the Widgets program.





4, build.


Locate the vcxproj file in%{builddir} and open it in Visual Studio.


5. Build with Visual Studio.


Then open the $${qtdir}/bin/qtd3dservice program, which will use the online compile shader. With deployment, remember that the deployment steps must be followed by opening the Qtd3dservice program.


6. Operation


Now the program is already on the phone, do not close Qtd3dservice, run the program, you can see the results.






The Qtd3dservice program is easy to strike. If the Qtd3dservice program always displays qt.d3dservice:Unable to get remote directory info: "?????", then it is possible that the above steps are wrong or other unknown error. In short, delete the built directory, starting with the fourth step to start again.


Summarize


QT's Windows Phone Suite is not perfect, mainly reflected in two points: 1, the online compilation shader need Qtd3dservice, to our development added trouble, test run must run the program, but also easy to strike. This program is removed from QT 5.4, 2, cannot be completely detached from Visual Studio, although Qt creator can run the program directly, but is not able to display the interface (missing Qtd3dservice run) is the font display box. Font display blocks the problem stems from Winrtrunner, the program's default definition of the program suffix that needs to be packaged does not have. ttf, and QT Creator cannot generate a map file for the Windows Phone suite. For this reason I made a bug on Jira and I hope they can solve the problem in the next version.



Real beat Operation:












Let Qt for Windows Phone 8.1 run on a real machine


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.