Let Qt for Windows Phone 8.1 perform on the real machine

Source: Internet
Author: User





Let Qt for Windows Phone 8.1 perform on the real machine






Several of the previous posts are intended for this article and are finally designed to use the QT framework to create programs that can be executed on a Windows Phone 8.1 real machine. Because Qt for WP8 this piece is not intact, 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, coupled with a bit of research, the development of QT for Windows Phone 8 was slightly understood.



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



Using QT to develop Windows Phone 8 applications and can be performed on the real machine, on the basis of the previous article, you need to register the developer account, and unlock the phone, so the ability to successfully develop.



The software you need to work with is QTSDK for Windows runtime, QT Creator3.1.2 (bundled in Qt for Windows Runtime), and the visual Studio 2012 or higher version number (included).


Let the Widgets program execute 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 a desktop suite, execution, is the result:






Good. Next, you'll learn how to migrate to a Windows Phone 8.1 platform. Select the kit for Windows Phone 8, and then add your own defined build steps in the "Build" column, for example.






The command is Qmake, the number is-TP Vc%{sourcedir}/%{currentproject:name}.pro "CONFIG+=WINDEPLOYQT", working folder 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 then execute it from your phone, and you're done. It's so simple.





Let the quick program execute on the real machine


Here's how the Qtquick program executes on a Windows Phone 8.1 real machine.


1. In the same way, set up a QT Quick project:





Let's do this first with a desktop suite, which is the effect:





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


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



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



We are able to find all the available fonts in $$[qt_install_bins]/fonts, of course you can add the fonts you like and if you don't set them, they will be packaged. So setting fonts as a valid font is good, but assuming that the settings fonts=, it will cause no fonts available, the execution of the program will appear a block.


3, for the project to add their own definition of processing steps.


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. Implementation


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






Qtd3dservice program very easy strike. Assuming that the Qtd3dservice program always shows qt.d3dservice:Unable to get remote directory info: "?????", then it is possible that the above steps are wrong, or other unknown errors. In short, delete the built folder from the fourth step and start again.


Summarize


QT's Windows Phone Suite is not intact, the main body now two points: 1, the online compilation shader need to Qtd3dservice, to our development added trouble, test execution must execute the program, but also easy strike. This program is removed from QT 5.4, 2, cannot be completely detached from Visual Studio, although Qt Creator can execute the program directly, but it is not impossible to display the interface (missing Qtd3dservice execution) 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 put a bug on Jira and I hope they can solve this problem in the next version number.



Real Pat Execution:












Let Qt for Windows Phone 8.1 perform on the 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.