QT makes software disk

Source: Internet
Author: User

Recently engaged in a tissue cell dehydration machine project, of course, for domestic projects are imitation to go, we are no exception, the first to see the interface is the user login interface, need to input Chinese, as a programmer, my first reaction is what I need to use the framework to do this interface, Direction is multifaceted, certainly will choose oneself familiar of one, naturally, I chose Qt to do interface, but QT did not like Android, ios,c# and so on support so perfect, after all, do not so many people, so relatively not so perfect. We do not have a peripheral such as a mouse and keyboard, and all user interaction is done by touching the display. The first problem encountered here is: QT soft keyboard production. Let's get down to the chase and how I solved the problem.

The first stage----find Syszuxpinyin source

Like most people, encounter a problem will not solve, first ask Baidu how to look at the big God, on-line search QT Soft keyboard, there are a variety of solutions, some I also download run, not very easy to use, some still need money, for money, can understand, but I think not necessary. Finally, I chose a very close to the embedded QT soft keyboard ideas, Syszuxpinyin Click to open the link, the source code after downloading, in accordance with the specified method of transplantation, on the arm board running, found that there are two problems;

First: The content in Qlineedit is always append in the back; second: You cannot click a control repeatedly;

The second stage----modify Syszuxpinyin source code

With the previous two questions, I Baidu, found another blog Click to open the link, according to one of the methods to modify, but found that there is a problem, just click on the soft Keyboard back button, the program died there, eventually after the troubleshooting, the program problem in a statement current_focus_ Widget = Qapplication::focuswidget (); Later, chat with friends in the group to know that in the embedded QT version, using this method to get focus is a bug.

The third stage----detailed analysis Syszuxpinyin source code

Now that we have not found the exact matching method, and have studied so long Syszuxpinyin, decided to syszuxpinyin the source code thoroughly understand, see if there is more harvest

The Syszuxpinyin code that made the comment is as follows address: Http://pan.baidu.com/s/1i56lUiL

Analyzing the Syszupinyin Architecture:

The architecture of the Syszupinyin is made up of two parts

The first part: The soft keyboard interface, obtains the user input string, matches the Chinese characters in the font character or displays the English, displays in the Qlineedit, the click Returns, the Chinese character or the English sends out.

Part II: Subclasses of Qwsinputmethod

In the second part, the automatic focus failure occurs because of a bug in the Qapplication::focuswidget () problem that is acquired by the interface focus. So since the focus fails, then the control becomes the focus, and you can say it yourself, and converting it into a programming method is the Mousepressevent method of overriding the control.

Phase IV----Realization of embedded QT soft keyboard

According to the Syszuxpinyin soft keyboard interface code and rewrite the input control Mousepressevent method to implement the embedded QT soft keyboard, in fact, not only the embedded version can be used, PC version can also be used.

Ideas:

1 Rewrite the Mousepressevent method of the input control, emit the signal in the Mousepressevent method, and send the string out, after the main window receives the signal, opens the corresponding slot function, opens the soft keyboard interface in the slot function, And the string sent over the signal is displayed in the soft keyboard interface.

2 after opening the soft keyboard, you can choose Chinese and English input method in the interface, if it is an English input method, it is directly displayed, if it is the input methods, according to the input of the English characters to match the field in the font, and then displayed

3 Click on the soft keyboard to return the key, send a signal to send the string (English or Chinese) to the input component of the main window and display.

If the feeling is helpful, trouble points a praise!!!

Source Address Download: HTTP://PAN.BAIDU.COM/S/1NVCRBFJ

Running slices:

Chinese input

English input

The above is my QT soft keyboard thinking, although the interface does not look good, but the function has come out, and the interface can also beautify themselves, Master seeking advice!!!

QT makes software disk

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.