Idea of the client UI framework that requires frequent control adjustment

Source: Internet
Author: User

The title is a little long, but I have explained what I want to explain in general. Kids shoes that have worked on client UI programming often encounter different display resolutions, customer requirements, and other reasons that require constant layout adjustment. Qt itself has an Adaptive Layout. Just like a spring, you can modify parameters similar to the elastic coefficient to adjust the position of the Adaptive Layout. However, in most cases, the requirements are still not met. For example, if the number of the Two-row controls is different, the first and second rows of the two controls must be strictly aligned. This uncontrolled factor often causes the use of fixed positions based on pixels or proportions to calibrate the exact position of the control.

In this context, a large amount of time is spent constantly re-Compiling and constantly adjusting the control position. This operation becomes boring and time-consuming, especially when the UI interface needs to be adjusted only when complex operations are required for some businesses.

To solve this problem, we can design a new UI framework. There are only two requirements:

① In debug mode, the location can be written in the configuration file based on pixels or proportions; in release mode, the location specified in the configuration file can be written to the deadCode.

② You can set compilation parameters or macro definitions. When you only focus on interface adjustment, You can compile the compilation independently of the business logic. All UI logic-related interfaces still provide corresponding interface responses, the remaining non-UI logic-related interfaces all exist in a queue. After compilation and running, the interface is displayed as a directory. In this case, the operation is only related to the UI resources and UI logic, and there is no executable business data.Program.

Preliminary ideas:

For requirement 1, debug macro is required to set whether to read the configuration file. The technical point is that before release compilation, an external program is started [simple script is enough, but basic C/C ++ assignment statements need to be recognized]. switch the code for reading location information from the configuration file to a fixed value. The optimization method is to prepare two sets of code before the framework is generated, and then update the second set directly. For example

 
// Ui_framework_begin -- used to define the start position required by the script # If _ debug POS. X = getconfig ("POS", "x "). toint (); # else POS. X = 0; // the value to be updated # endi // ui_framework_end -- defines the end position of the script modification.

For requirement 2, you need to set exclusive code. When a macro such as set_pos_only is opened, non-ui-related code can be automatically commented out without affecting the UI logic. Generally, business data and UI logic are mixed together. Business Code is not block-based and can be calibrated by simply adding the methods to define the start and end positions required by the script in requirement ①, if the exclusive code is inserted manually, the meaning of the so-called UI framework is lost. The current method is to take functions as the test object. Before the code called by the UI, add # endif // set_pos_only, next, traverse the code to the first code that is not called by the UI and add # If
! Set_pos_only. For example

 
# Endif // set_pos_onlyshow (Pos, edit); show (...) ...... # If! Set_pos_onlyprint ("Hello World"); # endif // set_pos_onlyshow (Pos, edit); show (...)

Then, from the inside of the function, add the position closest to the start position without an error # If! Set_pos_only. The basis for finding this position is: Search for the first # endif // set_pos_only in the function, find the statement called by the local variable in the first function, and add it below it.

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.