Analysis of new features of Qt4.7 Qt Quick development process

Source: Internet
Author: User

Qt4.7New FeaturesQt quickThe development process is the content to be introduced in this article.Qt QuickThe development process. I went to the office early this morning.QtOfficial website, the long-awaited official version of 4.7 is still unavailable. However, you can't wait to share with us the new features of 4.7. The following describes how to read and understand multiple official documents and the results of your own instance authentication.

Qt4.7The new features are as follows:

1) brand new Qt quick UI development tool

It includes three modules. The following will detail how these three modules work, what are the relationships, and what benefits can they bring to developers.

2) Qt Quality Improvement

Well, there must be some improvement. Because 4.7 adopts the first version developed by the new Qt Continuous Integration system. The so-called Qt Continuous Integration system. To put it bluntly, the performance test experiment has done a little more. When the new version of Qt adds or modifies a function, the system can test the added modules. If it has a bad impact on the performance of other parts of Qt, this action will be canceled. That is to say, we can ensure that the later versions of Qt will certainly be more optimized than the previous ones.

3) webkit update

Qt 4.7 uses the latest webkit2.0 module. Supports hardware-accelerated CSS and 3D animation.

4) Qt creator 2.0

Creator2.0 focuses on the convenience of mobile developers. Added support for the development environments of seban and maemo.

The Qt quick tool consists of three parts. Now let's take a look at the content and functions of these three parts in sequence.

1. QMLQt (Object Definition Language) is used to explain and describe the UI. The language format is similar to CSS, and the function is similar to JavaScript. Let's take a look at the QML code. Even this code string does not need to be explained. The file name is qml. The qml file is just an interface that can be static or dynamic .) Qml can implement many complex dynamic ui interactions. For more information, see the qt demo.

 
 
  1. Rectangle {  
  2. id: rectangle1  
  3. x: 208  
  4. y: 31  
  5. width: 100  
  6. height: 100  
  7. color: "#2afd00"  
  8. radius: 50  
  9. border.width: 0  

2. The new tool Design is in creator2.0. Image evidence:

The biggest advantage of the qml and design tools is the ability to implement two-way dynamic interaction between qml scripts and the ui. This cannot be implemented in previous versions of tool designer. Qml is an explanatory scripting language, which facilitates ui development.

So how can we add the designed qml file to the qt project? That is, how to use qml In the qt application. Here, we naturally enter the third part.

3. QtDeclarative

This module is used to load the ui. Check the code first. This is an example of objectlistmodel of qt declarative.

First, let's take a look at the pro file of objectlistmodel:

 
 
  1. TEMPLATE = app
  2. TARGET = objectlistmodel
  3. QT + = declarative
  4. # Input
  5. SOURCES + = main. cpp \
  6. Dataobject. cpp
  7. HEADERS + = dataobject. h
  8. RESOURCES + = objectlistmodel. qrc
  9.  
  10.  
  11. Main. cpp file of objectlistmodel:
  12. # Include <QApplication>
  13. # Include <qdeclarativeengine. h>
  14. # Include <qdeclarativecontext. h>
  15. # Include <qdeclarative. h>
  16. # Include <qdeclarativeitem. h>
  17. # Include <qdeclarativeview. h>
  18. # Include "dataobject. h"
  19. Int main (int argc, char ** argv)
  20. {
  21. QApplication app (argc, argv );
  22. QDeclarativeView view;
  23. QList <QObject *> dataList;
  24. DataList. append (new DataObject ("Item 1", "red "));
  25. DataList. append (new DataObject ("Item 2", "green "));
  26. DataList. append (new DataObject ("Item 3", "blue "));
  27. DataList. append (new DataObject ("Item 4", "yellow "));
  28. QDeclarativeContext * ctxt = view. rootContext ();
  29. Ctxt-> setContextProperty ("myModel ",
  30. QVariant: fromValue (dataList ));
  31. View. setSource (QUrl ("qrc: view. qml "));
  32. View. show ();
  33. Return app.exe c ();
  34. }

You can see that the class QDeclarativeView is used to load the ui.

Then we can write an application and load the 12. qml in the figure into an exe file.

The main. cpp code I used is as follows:

 
 
  1. QApplication a(argc, argv);  
  2. QDeclarativeView vi;  
  3. vi.setSource(QUrl(“12.qml”));  
  4. vi.setResizeMode(QDeclarativeView::SizeRootObjectToView);  
  5. vi.show();  
  6. return a.exec(); 

OK. Now the performance of QT4.7 has been introduced. Through this introduction, we also know the basic process of 4.7 app development. If you have any bugs, please correct them.

Summary: AnalysisQt4.7New FeaturesQt QuickThe content of the development process has been introduced. I hope this article will help you!

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.