Why QT becomes the first choice for C + + interface programming

Source: Internet
Author: User
Tags qt designer

First, Preface

Why now qt More and more become the first choice of interface programming, the author of the QT Interface programming has been nearly 8 years, before this I do C + + interface is based on MFC, also done about 5 years. At that time why the transfer from MFC to QT, the main reason is that MFC development interface to do a good look some very difficult, referring to the third-party MFC-based Interface library code is also relatively confusing, at that time, mainly to see Qt has QSS style design This function, decided to try. When the project migrated to QT, I think MFC really can be discarded, MFC is too many shortcomings compared to QT. Of course, MFC also has a fatal flaw that cannot cross the platform.

Of course some classmates may say why not use directly C # WPF does the interface, and some of our projects and tools are really done in C #, and C # and C + + can really call each other, and you can debug breakpoints. But there are still a lot of losses in performance. We do have an impact on our audio and video and three-dimensional simulation projects, so we only use C # in some projects that have no extreme performance requirements.

Second, QT History

Having said a few things about our project, let's briefly introduce QT History, know that the purpose of history is to determine whether the use of this library is risky, whether it will stop the update, many open source libraries are not commercialized and eventually stopped.

l QT by Development of Science and technology company

L 2008 Nokia acquires QT from the tech company and adds LGPL's licensing model

L 2011 Finland's Digia acquired QT from Nokia Commercial Edition right, from this Nokia is responsible for QT on Mobile, QT commercial by Digia

The culmination of QT's development was when Nokia smartphones were at its peak, when Nokia's Symbian system was heavily based on Qt, and with the popularity of Apple and Android, Symbian withdrew from the historical stage. QT's mobile-phone development needs are also largely replaced. However, QT application in embedded, power system, military system has not been replaced.

Third, QT now use case

To understand his current situation, the main consideration is whether the application scenario is many, whether the employment is wide, talent is good recruitment.

QT is widely used in embedded, power systems, military systems and other hardware interface systems to interact with, and a large number of professional cross-platform application software is also the use of QT development.

Digia took over QT and developed the Android and iOS versions of QT, enabling the development of a program to run on a full platform. However, it is not recommended to use QT to develop Android and iOS apps, but the pits are more but surely more perfect.

we list QT Development the software:

1.Autodesk May: Avatar and Kung Fu Panda 3D animation software

2.WPS: in the WPS directory, you can see the DLL library of QT

3. PowerWord

4.google Earth

5. Skype for Microsoft

6.VirtualBox (Oracle's virtual machine software)

(Too many of them are not listed.)


Four, QT the tools provided

look again . What Tools QT offers, QT not only provides a feature-rich SDK development package, but also provides a powerful tool, which is one of the reasons we chose him.

1. VS -based plugin Qt-vs-addin

The latest version provides versions 2013 and 2015, the old version is not currently available, but now the basic mainstream of C + + development is at least vs2013.

650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/16/111af113cde2830688f25c6a94bbc450.jpg-wh_500x0-wm_3 -wmp_4-s_105735737.jpg "title=" 7.jpg "alt=" 111af113cde2830688f25c6a94bbc450.jpg-wh_ "/>

2. Qt Assistant ( manual )

The QT manual is still quite complete and contains many examples of source code.

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/16/dfc182826b30ae99f1b1211f8bd67dbf.jpg-wh_500x0-wm_3 -wmp_4-s_1232369123.jpg "title=" 8.jpg "alt=" Dfc182826b30ae99f1b1211f8bd67dbf.jpg-wh_ "/>

3. XML -based interface designer Qt designer

the convenient decoding design, should be the most convenient interface designer for the C + + domain.

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/16/2360b29267523078049b88f4abd0b0fa.jpg-wh_500x0-wm_3 -wmp_4-s_2430968875.jpg "title=" 9.jpg "alt=" 2360b29267523078049b88f4abd0b0fa.jpg-wh_ "/>

4. Cross-platform development tools Qtcreator

Cross-platform C + + development tools, should be the most convenient C + + development debugging Tools on Linux, even without the QT library, it can also be used to develop cross-platform C + + projects.

650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/16/f77d9d7dd952d8ccf8fec319b597f24a.jpg-wh_500x0-wm_3 -wmp_4-s_1613925646.jpg "title=" 10.jpg "alt=" F77d9d7dd952d8ccf8fec319b597f24a.jpg-wh_ "/>

v. QT Framework Benefits

Finally, let's take a look what are the specific advantages of QT?

1. Rich Tools

This has been introduced in front of the tool.

2. Feature- rich

Provides an interface library, and also provides an audio library, 3d Library, database sdk,webengine, network library and so on, let us do cross-platform program becomes simple.

3. Open Source and cross-platform

out of the can own through QT Source for the transplant, the official QT has provided a re-windows,android,ios,linux run in the SDK.

4. Benefits of Architecture

There are a lot of advantages to this, and we've listed some examples to see the benefits.

interface source code and user source isolation , QT strategy is that no interface will generate a corresponding source code, such as having an interface design file Xps.ui It will parse the XML generated a corresponding ui_xps.h file, this file you do not need to modify, if you want to invoke the interface control directly through the Ui::xpsclass Ui This object definition is also written in Ui_xps.h. That is, your business logic is isolated from the creation and setup of interface control objects.

Convenient event handling (flexible signal slot mechanism) , QT provides a signal slot mechanism, which can reduce coupling and improve the reusability of code.

For example there is such a requirement that one of my Xmov class specialized in processing video, but to the processing progress to inform the external interface Xslider object, I deal with the method, can Xmov provide an interface to external access to progress, or actively call the external interface to refresh the display progress, the first method of real-time is not guaranteed, and the interface end program also needs to introduce the Xmov class header file, that is, to do the correlation. The second method makes the Xmov class more coupled, and the Xmov class needs to be modified when the interface is changed. QT in the signal slot mechanism can be associated with two classes Xmov and Xslider, in Xmov directly define a signal function void SetPos (int), directly bound to the Xslider object of the void SetPos (int) slot function, they do not know each other, Reduce coupling. Only the signal slots of each module are associated in the unified portal class.

Xmov::run ()

{

while (!sexit)

{

Working with Videos

int pos = Dealmove ();

Signal, if the signal is not bound, the pace will not be a problem

SetPos (POS);

}

}

Binding method

Connect (xmov,signal (SetPos (int)), Xslider,slot (SetPos (int)))

This is an advantage of the signal slots, and of course the signal slots are also custom events for handling various types of controls.

5. and its convenient style design (like the development of Web programs to design the interface)

can easily make a rounded border, and have a gradient effect, the mouse moved up also changes, you can refer to the following style sheet, QSs is basically similar to CSS, including a CSS-enabled selector, which can be set by class name, object name, and parent class name.

650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/16/663d2dcb6f8d86db48c649ca4e24301b.gif-wh_500x0-wm_3 -wmp_4-s_3489436162.gif "title=" 12.gif "alt=" 663d2dcb6f8d86db48c649ca4e24301b.gif-wh_ "/>

Qpushbutton:!hover

{

Background-color:qlineargradient (Spread:pad, x1:0, y1:0, x2:0, Y2:1, stop:0 Rgba, 255), stop:0.495 Rgba (39, (255), stop:0.505 Rgba (39,39, 255), Stop:1 Rgba (120, 120,120, 255));

border-radius:5px;

}

Qpushbutton:hover/* Hover mouse hover */

{

Background-color:qlineargradient (Spread:pad, x1:0, y1:0, x2:0, Y2:1, stop:0 Rgba, 255), stop:0.495 Rgba (120, 1 255, stop:0.505 Rgba (120,120, 255), Stop:1 Rgba (39, 39, 39, 255));

border-radius:5px; /* Rounded Border */

}

will be rolled out later QT related articles, this article mainly to do a brief introduction, the following will be divided into detailed explanation.


Read more about my 51cto Academy video Course


More information can also focus on my 51cto video course

Summer Teacher's Classroom http://edu.51cto.com/lecturer/12016059.html


C + +QT5 cross-platform interface programming principles and practical video courses

Http://edu.51cto.com/course/11507.html

650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/16/9e5d75b6fed34e1b86d17307bb5e9309.jpg-wh_500x0-wm_3 -wmp_4-s_3655684438.jpg "title=" 11.jpg "alt=" 9e5d75b6fed34e1b86d17307bb5e9309.jpg-wh_ "/>


This article from "Xia Chaojun" blog, reproduced please contact the author!

Why QT becomes the first choice for C + + interface programming

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.