Precautions for migrating QT Symbian mobile apps

Source: Internet
Author: User

If you have developed your applications on Linux and Windows, you may find that you are porting your applications.
It is not that consistent with the user habits on the mobile phone. In addition, many training materials are teaching QT
It is also applicable to desktop applications. This problem also occurs for beginners who compile them into a mobile phone version based on the example in the training materials. Here I will sort out several frequently encountered problems.

Qwidget or qmainwindow

The difference between qmainwindow and qwidget is that qmainwindow contains the toolbar, Status Bar, and menu. The biggest difference visible to mobile apps is the menu, that is, the "options" option in the lower left corner.

Therefore, if your application is complicated and you need to use menu processing, use qmainwindow as the main window of your application.
Port. When using qmainwindow, beginners often encounter another problem: they add new controls to qmainwindow and use qlayout to manage these controls.
Often fail. The reason is that qmainwindow has its own layout manager. If you need to add new controls and la s in qmainwindow, you can use
Qmainwindow: setcentralwidge (qwidget *) sets a qwidget for the main interface of qmainwindow
* CW, and then define your own layout and controls in CW.

 

Customized Options Menu

You can use the qmainwindow: newmenubar () function to obtain the menu bar of the main window (if there is no menu bar, create one and return
You can use addmenu () or addaction () to add sub-items to the menu bar. If no sub-menu item exists, we recommend that you use addaction directly, because if no sub-menu item exists
Method to directly respond to external events.

Custom system softkey content in
When an application has multiple views, if the system's softkey (that is, the soft key at the bottom of the screen) always displays "options" and "exit", the application cannot be requested. For example, after leaving the main interface,
Change "exit" to "back ". You can bind a qaction to a softkey by using the setsoftkeyrole () function of qaction.
Qaction text/text () is also displayed on softkey. The context of the current softkey and controls with the current input focus. If you want to add sub-options to the customized softkey, you can use qaction: setmenu () to implement it. Window Maximization

In most of the "Hello, world" examples, the show () function is used to display the window. However, on the mobile phone system, I recommend using showmaximized (), that is, maximization.

This ensures that the background of the screen is exposed by other applications when the form is displayed. In addition, if showmaximized () is used (), when the mobile phone is changed from horizontal to vertical (or vice versa ),
The application window is automatically adjusted when the machine screen changes. If the show () function is used, the size of the application window is retained when the horizontal position of the mobile phone changes, which may cause the window to exceed
Screen, or leave uncovered areas on the screen. Multi-Window application development complex applications will have many
View. If it is developed on the desktop system, we can choose to manage multiple sub-windows through mdi in a qmainwindow. However, it is not suitable for mobile phone screen space limitations.
In combination, mobile apps need to maintain the largest interface space in each view. It is better to achieve direct switching between different views through some method. To switch between qsatckedwidget and qstackedlayout to manage multiple views, QT provides two convenient classes. The difference between qstackedwidget and qsatckedlayout is that qsatckedwidet inherits from qwidget as a visual control, while qstackedlayout inherits from qlayout and is only responsible for layout. Each control view added to qstackedwidget or qstackedlayout obtains an index number (INDEX). qstackedwidget or qstackedlayout can use setcurrentindex to specify which control view is currently displayed. When the current display view in qstackedwidget/qstackedlayout changes
Returns a currentchanged (INT) signal. developers can use this signal to perform corresponding operations, such as updating the current context menu or softkey (previous section ).
), And change the title of the window according to the current view.

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.