A file generation method, electronic device, and storage medium
By loading the analysis program to the target application, automatically analyzing the control tree and generating source code, the cumbersome problem of Qt application interface rewriting in the existing technology is solved, and the interface is quickly written and high accuracy is achieved.
Patent Information
- Application Number
- CN202110955275.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-19
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2041-08-19
AI Technical Summary
In the prior art, development engineers need to redevelop the Qt application written by the QWidget tool into a Qt Quick application and rewrite the user interface, resulting in heavy workload, boring and repetitive work.
By loading the analysis program to the target application, the analysis program automatically analyzes the control tree of the target application, and generates the target source code and saves it as a target file to achieve rapid writing of the interface.
No need to rewrite the interface, saving a lot of labor costs and improving the accuracy of interface restoration.
Smart Images

Figure CN113760286B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer information processing technology, and more particularly to a method for generating a file, an electronic device, and a storage medium. Background Art
[0002] Qt is an application development framework that provides a cross-platform class library, integrated development tools, and a cross-platform integrated development environment (IDE). Qt can be used to develop applications. Furthermore, Qt can be used to deploy applications across different desktop and embedded operating systems. Applications developed with Qt are called Qt applications.
[0003] Personal computers (PCs) use the QWidget tool to write Qt applications. However, with the rapid development of mobile devices, on the one hand, Qt applications written with the QWidget tool need to be redeveloped using the Qt Quick tool, and the user interface (UI) written with QWidget needs to be rewritten using the qml tool; on the other hand, sometimes it is necessary to refer to the UI of the Qt Quick application and compile the qml file into the binary file of the Qt Quick application. To do this, development engineers need to rewrite it using the qml tool according to the current Qt application UI, which is boring and repetitive, and consumes a lot of manpower. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present application provide a file generation method, an electronic device, and a computer-readable storage medium.
[0005] The file generation method provided in the embodiment of the present application includes:
[0006] Load the analysis program into the target application;
[0007] Analyzing the target application using the analysis program to obtain a control tree of the target application;
[0008] A target source code is generated based on the control tree, and the target source code is saved as a target file, wherein the target source code refers to a source code in a target format, and the target file refers to a file in a target format.
[0009] The file generation device provided in the embodiment of the present application includes:
[0010] A loading unit for loading the analysis program into the target application;
[0011] An analysis unit, configured to analyze the target application using the analysis program to obtain a control tree of the target application;
[0012] A generating unit, used for generating a target source code based on the control tree;
[0013] A saving unit, used for saving the target source code as a target file;
[0014] The target source code refers to a source code in a target format, and the target file refers to a file in a target format.
[0015] The electronic device provided in an embodiment of the present application includes: a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute any one of the above-mentioned file generation methods.
[0016] The computer-readable storage medium provided in the embodiment of the present application stores a computer program, and when the computer program is executed by a processor, any one of the above-mentioned file generation methods is implemented.
[0017] In the technical solution of the embodiment of the present application, the analysis program is loaded into the target application, and the target application can be automatically analyzed by the analysis program, thereby obtaining the target source code of the current interface of the target application, and the target source code is saved as a target file, which is a file of the interface written in the target format, thereby realizing the rapid writing of the interface. Compared with the prior art, the technical solution of the embodiment of the present application does not need to rewrite the interface, saving a lot of labor costs, and also improving the accuracy of interface restoration. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a flowchart of a file generation method provided in an embodiment of the present application;
[0019] Figure 2 is a schematic diagram of controls in a UI interface provided in an embodiment of the present application;
[0020] Figure 3 It is a structural diagram of the number of controls provided in the embodiment of the present application;
[0021] Figure 4 This is a flow diagram of a method for generating a qml file based on a running Qt application provided in an embodiment of the present application. Figure 1 ;
[0022] Figure 5 This is a flow diagram of a method for generating a qml file based on a running Qt application provided in an embodiment of the present application. Figure 2 ;
[0023] Figure 6 It is a schematic diagram of the structure of the file generation device provided in an embodiment of the present application;
[0024] Figure 7 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;
[0025] Figure 8 It is a schematic structural diagram of the chip of an embodiment of the present application. DETAILED DESCRIPTION
[0026] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0027] It should be noted that in the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the embodiments of the present application, the character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0028] It should be understood that the "indication" mentioned in the embodiments of the present application can be a direct indication, an indirect indication, or an indication of an association relationship. For example, A indicates B, which can mean that A directly indicates B, for example, B can be obtained through A; it can also mean that A indirectly indicates B, for example, A indicates C, and B can be obtained through C; it can also mean that there is an association relationship between A and B.
[0029] In the description of the embodiments of the present application, the term "corresponding" may indicate a direct or indirect correspondence between two items, or an association relationship between the two items, or a relationship between indication and being indicated, configuration and being configured, and the like.
[0030] To facilitate understanding of the technical solutions of the embodiments of the present application, the technical solutions of the present application are described in detail below through specific embodiments. The above related technologies can be combined arbitrarily with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application. The embodiments of the present application include at least part of the following contents.
[0031] The key technical terms in the embodiments of the present application are explained below.
[0032] Qt application: A Qt application is an application developed using Qt. Here, Qt is a cross-platform C++ graphical user interface (GUI) application development framework. Qt application can also be called Qt GUI application.
[0033] Qt Quick: Qt Quick is an advanced user interface technology provided by Qt. It can be used to create UI for mobile devices. Qt Quick provides all the necessary basic types for creating UI based on qml tools. Qml tools provide qml engine and language parsing foundation.
[0034] QObject: QObject is the base class of all Qt classes. Most Qt classes inherit from QObject.
[0035] Introspection: Introspection is the ability of object-oriented languages to query information about objects during runtime.
[0036] Figure 1 is a flowchart of a file generation method provided in an embodiment of the present application, such as Figure 1 As shown, the file generation method includes the following steps:
[0037] Step 101: Load the analysis program into the target application.
[0038] In the embodiment of the present application, the analysis program may also be referred to as a parsing program or an analysis conversion program or an analysis tool or a parsing tool or an analysis conversion tool. The present application does not limit the name of the analysis program.
[0039] In the embodiment of the present application, the target application is a Qt application. The Qt application internally uses a control tree to organize the hierarchy and position relationship of controls. As an example, Figure 2 The UI interface shown in the figure is used by the Qt application UI interface (i.e. a window interface). Figure 2 The control tree is constructed as shown. Control 1 has two child controls, namely Control 2 and Control 3; Control 2 has one child control, Control 4. Control 3 has two child controls, namely Control 5 and Control 6. Here, Control 1 is the root control.
[0040] The control tree corresponding to the UI interface of the running Qt application is as follows Figure 3 As shown, the analysis program is loaded into the Qt application, and the Qt application is analyzed to obtain the corresponding control tree information.
[0041] In some optional implementations, the target application is a Qt Quick application. In other optional implementations, the target application is a QWidget application. Here, a Qt Quick application refers to an application written using the QtQuick tool. A QWidget application refers to an application written using the QWidget tool. It should be noted that a Qt application is a binary program.
[0042] In an embodiment of the present application, the analysis program includes a dynamic link library. The dynamic link library of the analysis program is loaded into the target application. Further, the dynamic link library of the analysis program is loaded into the running target application, so that the dynamic link library will be loaded into the process space of the Qt application. Here, the running target application will display the corresponding interface.
[0043] It should be noted that loading the analysis program into the target application can also be described as injecting the analysis program into the target application, or attaching the analysis program to the target application, which have the same meaning.
[0044] In an embodiment of the present application, there may be many ways to load the dynamic link library of the analysis program into the target application. Two methods are listed below. It should be noted that the present application is not limited to the following two methods.
[0045] Method 1: Use a debugger to load the dynamic link library of the analysis program into the target application.
[0046] For example, the debugger uses the gdb command to call the dlopen function to load the dynamic link library of the analysis program into the target application.
[0047] Method 2: Use a dynamic linker to load the dynamic link library of the analysis program into the target application.
[0048] For example, a dynamic linker is used to preload the dynamic link library of the analysis program into the target application.
[0049] Step 102: Analyze the target application using the analysis program to obtain a control tree of the target application.
[0050] In the embodiment of the present application, the target application is analyzed by the analysis program to obtain the control tree of the target application, which can be achieved by the following steps:
[0051] Step 1) using the analysis program to search for at least one window displayed by the target application, each window in the at least one window corresponds to a control tree;
[0052] Step 2) Determine the control tree corresponding to the at least one window using the analysis program.
[0053] The following describes how to generate the control tree of the target application in combination with different implementations of the target application.
[0054] Solution 1
[0055] In the embodiment of the present application, the target application is a running Qt Quick application. Here, the QtQuick application can provide one or more of the following methods: allWindows method, topLevelWindows method, focusWindow method, contentItem method of QQuickWindow. The functions of these methods will be described in the following related schemes.
[0056] Here, the allWindows method, the topLevelWindows method, and the focusWindow method belong to the methods of the global variable qApp of type QG uiApplication.
[0057] The above step 1) can be implemented in the following ways: using the analysis program to call the allWindows method to find all windows displayed by the target application; or using the analysis program to call the topLevelWindows method to find all top-level windows displayed by the target application; or using the analysis program to call the focusWindow method to find the focus window displayed by the target application; wherein the allWindows method, the topLevelWindows method and the focusWindow method are methods provided by the Qt Quick application.
[0058] The above step 2) can be implemented in the following way: using the analysis program to call the contentItem method of QQuickWindow to traverse the at least one window to obtain a corresponding Qt Quick control tree, wherein the Qt Quick control tree includes at least one Qt Quick control; wherein the contentItem method of QQuickWindow is a method provided by the Qt Quick application.
[0059] Here, it should be noted that the contentItem method of QQuickWindow can be used to traverse and find all the controls in the control tree.
[0060] In some optional implementations, the analysis program is used to determine the control properties of at least some of the controls in the control tree, wherein the control properties are used to determine the association relationship between controls, and the control properties are also used to determine the control tree. Specifically, the analysis program is used to call the introspection capability of QObject to obtain the control properties of at least some of the controls in the control tree.
[0061] As an example: the analysis program calls QObject's introspection ability to find the widget properties of the widget, and determines whether the widget is the root widget based on the widget properties. After determining the root widget, other widgets in the widget tree can be found based on the root widget, and finally all the widgets in the widget tree are found.
[0062] Solution 2
[0063] In the embodiment of the present application, the target application is a running QWidget application. Here, the QWidget application can provide one or more of the following methods: allWidgets method, topLevelWidgets method, focusWidget method, and children method of QObject. The functions of these methods will be described in the following related schemes.
[0064] Here, the allWidgets method, the topLevelWidgets method, and the focusWidget method belong to the methods of the global variable qApp of type QApplication.
[0065] For the above step 1), it can be implemented in the following ways: use the analysis program to call the allWidgets method to find all windows displayed by the target application; or use the analysis program to call the topLevelWidgets method to find all top-level windows displayed by the target application; or use the analysis program to call the focusWidget method to find the focus window displayed by the target application; wherein the allWidgets method, the topLevelWidgets method and the focusWidget method are methods provided by the QWidget application.
[0066] For the above step 2), it can be implemented in the following way: use the analysis program to call the children method of QObject to traverse the at least one window to obtain the corresponding QWidget control tree, and the QWidget control tree includes at least one QWidget control; wherein the children method of QObject is a method provided by the QWidget application; based on the control mapping relationship table, map the QWidget control tree to a Qt Quick control tree, wherein the control mapping relationship table is used to express the mapping relationship between QWidget controls and Qt Quick controls.
[0067] Here, it should be noted that the parent class of QWidget is QObject, and all controls in the control tree can be traversed using the children method of QObject.
[0068] Further, in some optional implementations, the analysis program is used to determine the control properties of at least some controls in the control tree, wherein the control properties are used to determine the association relationship between controls, and the control properties are also used to determine the control tree. Specifically, the analysis program is used to call the introspection capability of QObject to obtain the control properties of at least some controls in the control tree.
[0069] As an example: the analysis program calls QObject's introspection ability to find the widget properties of the widget, and determines whether the widget is the root widget based on the widget properties. After determining the root widget, other widgets in the widget tree can be found based on the root widget, and finally all the widgets in the widget tree are found.
[0070] It should be noted that since the target application is a QWidget application, the control tree found through QObject is a QWidget control tree, and the QWidget control tree needs to be mapped (that is, converted and translated) into a Qt Quick control tree. The QWidget control tree can be mapped into a Qt Quick control tree using a predefined mapping relationship table of QWidget controls to Qt Quick controls. Here, the problem of automatic conversion of the QWidget control tree to the Qt Quick control tree is solved through the predefined mapping relationship table of QWidget controls to Qt Quick controls.
[0071] Step 103: Generate a target source code based on the control tree, and save the target source code as a target file, wherein the target source code refers to a source code in a target format, and the target file refers to a file in a target format.
[0072] In an embodiment of the present application, the control tree obtained through the above step 102 is a Qt Quick control tree, and the QtQuick control tree is translated into a qml source code, where the qml source code refers to a source code in the qml format; then, the qml source code is saved as a qml file, where the qml file refers to a file in the qml format.
[0073] The technical solution of the embodiment of the present application is to load the analysis program into the running Qt application (such as Qt Quick application or QWidget application), analyze the Qt application through the analysis program to obtain the control tree of the Qt application, translate the control tree into qml language and save it as a qml file, thereby realizing the reverse generation of qml files from the running Qt application. The technical solution of the embodiment of the present application can be used to quickly clone all or part of the interface of the Qt application.
[0074] The technical solution of the embodiment of the present application is illustrated below with reference to specific application examples.
[0075] Application Example 1
[0076] Figure 4 This is a flow diagram of a method for generating a qml file based on a running Qt application provided in an embodiment of the present application. Figure 1 ,like Figure 4 As shown, the method comprises the following steps:
[0077] Step 401: Load the analysis program into the Qt Quick application.
[0078] Here, the analysis program is loaded into the process space of the Qt application to be analyzed, and the analysis program is a dynamic link library.
[0079] In some alternative implementations, the analysis program can be loaded into a Qt Quick application using a debugger.
[0080] In some alternative implementations, the analysis program can be loaded into the Qt Quick application using a dynamic linker.
[0081] Step 402: Find the window displayed in the UI interface of the Qt Quick application through the analysis program.
[0082] In some optional implementations, the allWindows method may be called to search for all windows of a Qt Quick application.
[0083] In some optional implementations, the topLevelWindows method may be called to find all top-level windows of a Qt Quick application.
[0084] In some optional implementations, the focusWindow method may be called to find the focus window of the Qt Quick application.
[0085] Here, the allWindows method, the topLevelWindows method, and the focusWindow method belong to the methods of the global variable qApp of type QG uiApplication.
[0086] Step 403: Analyze the window displayed in the UI interface through an analysis program to determine the corresponding Qt Quick control tree.
[0087] Here, each window in the UI interface corresponds to a control. Figure 2 For example, the UI interface includes 6 controls, namely control 1, control 2, control 3, control 4, control 5 and control 6. Use the contentItem method of QQuickWindow to traverse all windows and determine the following: Figure 3 The control tree shown.
[0088] Step 404: The analysis program calls the introspection function of QObject to obtain the properties of the control.
[0089] Here, the properties of the controls are used to describe the association relationship between controls. Through the properties of the controls, it can be determined whether the control is a root control, and then the control tree can be determined based on the root control.
[0090] It should be noted that the present application does not limit the execution order of step 404 and step 403. Step 404 and step 403 may be executed simultaneously, or step 403 may be executed first and then step 404, or step 404 may be executed first and then step 403.
[0091] Step 405: Translate the Qt Quick control tree into qml source code.
[0092] Step 406: Save the qml source code to a qml file.
[0093] Application Example 2
[0094] Figure 5 This is a flow diagram of a method for generating a qml file based on a running Qt application provided in an embodiment of the present application. Figure 2 ,like Figure 5 As shown, the method comprises the following steps:
[0095] Step 501: Load the analysis program into the QWidget application.
[0096] Here, the analysis program is loaded into the process space of the Qt application to be analyzed, and the analysis program is a dynamic link library.
[0097] In some alternative implementations, the analysis program can be loaded into the QWidget application using a debugger.
[0098] In some alternative implementations, the analysis program may be loaded into a QWidget application using a dynamic linker.
[0099] Step 502: Search the window displayed in the UI interface of the QWidget application program through the analysis program.
[0100] In some optional implementations, the allWidgets method may be called to search for all windows of a QWidget application.
[0101] In some optional implementations, the topLevelWidgets method may be called to search for all top-level windows of a QWidget application.
[0102] In some optional implementations, the focusWidget method may be called to find the focus window of the QWidget application.
[0103] Here, the allWidgets method, the topLevelWidgets method, and the focusWidget method belong to the methods of the global variable qApp of type QApplication.
[0104] Step 503: Analyze the window displayed in the UI interface through an analysis program to determine the corresponding QWidget control tree.
[0105] Here, each window in the UI interface corresponds to a control. Figure 2 For example, the UI interface includes 6 controls, namely control 1, control 2, control 3, control 4, control 5 and control 6. The parent class of QWidget is QObject. Use the children method of QObject to traverse all windows and determine the following: Figure 3 The control tree shown.
[0106] Step 504: The analysis program calls the introspection function of QObject to obtain the properties of the control.
[0107] Here, the properties of the controls are used to describe the association relationship between controls. Through the properties of the controls, it can be determined whether the control is a root control, and then the control tree can be determined based on the root control.
[0108] It should be noted that the present application does not limit the execution order of step 504 and step 503. Step 504 and step 503 may be executed simultaneously, or step 503 may be executed first and then step 504, or step 504 may be executed first and then step 503.
[0109] Step 505: Use a predefined mapping relationship table to map the QWidget control tree into a Qt Quick control tree.
[0110] Here, the mapping relationship table is used to describe the mapping relationship between the QWidget control and the Qt Quick control. Through the mapping relationship table, the QWidget control tree can be mapped to the Qt Quick control tree.
[0111] Step 506: Translate the Qt Quick control tree into qml source code.
[0112] Step 507: Save the qml source code to a qml file.
[0113] The technical solution of the embodiment of the present application provides a method for generating qml source code based on a Qt application. For a running Qt application, the UI interface that needs to be analyzed will be displayed. By loading the analysis program into the Qt application, the qml file corresponding to the UI interface can be automatically generated. Compared with the existing method in which the entire UI interface needs to be rewritten by the development engineer, the method of the present application saves a lot of labor costs and improves the accuracy of UI interface restoration.
[0114] Figure 6 Schematic diagram of the structure of the file generating device provided in the embodiment of the present application, which is applied to electronic devices such as Figure 6 As shown, the file generating device includes:
[0115] A loading unit 601, used to load the analysis program into the target application;
[0116] An analysis unit 602 is used to analyze the target application using the analysis program to obtain a control tree of the target application;
[0117] A generating unit 603, configured to generate a target source code based on the control tree;
[0118] A saving unit 604 is used to save the target source code as a target file;
[0119] The target source code refers to a source code in a target format, and the target file refers to a file in a target format.
[0120] In some optional implementations, the analysis program includes a dynamic link library; the loading unit 601 is used to load the dynamic link library of the analysis program into the target application.
[0121] In some optional implementations, the loading unit 601 is used to load the dynamic link library of the analysis program into the target application using a debugger; or to load the dynamic link library of the analysis program into the target application using a dynamic linker.
[0122] In some optional implementations, the analysis unit 602 is specifically used to use the analysis program to search for at least one window displayed by the target application, each of the at least one window corresponds to a control tree; and use the analysis program to determine the control tree corresponding to the at least one window.
[0123] In some optional implementations, the target application is a running Qt Quick application.
[0124] In some optional implementations, the analysis unit 602 is specifically configured to:
[0125] Using the analysis program to call the allWindows method to find all windows displayed by the target application; or,
[0126] Using the analysis program to call the topLevelWindows method to find all top-level windows displayed by the target application; or,
[0127] Using the analysis program to call the focusWindow method to find the focus window displayed by the target application;
[0128] The allWindows method, the topLevelWindows method, and the focusWindow method are methods provided by the Qt Quick application.
[0129] In some optional implementations, the analysis unit 602 is specifically configured to:
[0130] Using the analysis program to call the contentItem method of QQuickWindow to traverse the at least one window, and obtain a corresponding Qt Quick control tree, wherein the Qt Quick control tree includes at least one Qt Quick control;
[0131] The contentItem method of the QQuickWindow is a method provided by the Qt Quick application.
[0132] In some optional implementations, the target application is a running QWidget application.
[0133] In some optional implementations, the analysis unit 602 is specifically configured to:
[0134] Using the analysis program to call the allWidgets method to search for all windows displayed by the target application; or,
[0135] Using the analysis program to call the topLevelWidgets method to find all top-level windows displayed by the target application; or,
[0136] Using the analysis program to call the focusWidget method to find the focus window displayed by the target application;
[0137] Among them, the allWidgets method, the topLevelWidgets method and the focusWidget method are methods provided by the QWidget application.
[0138] In some optional implementations, the analysis unit 602 is specifically configured to:
[0139] Using the analysis program to call the children method of QObject to traverse the at least one window, and obtain a corresponding QWidget control tree, wherein the QWidget control tree includes at least one QWidget control; wherein the children method of QObject is a method provided by the QWidget application;
[0140] Based on the control mapping relationship table, the QWidget control tree is mapped to a Qt Quick control tree, wherein the control mapping relationship table is used to express a mapping relationship between a QWidget control and a Qt Quick control.
[0141] In some optional implementations, the generating unit 603 is specifically used to translate the Qt Quick control tree to obtain a qml source code, where the qml source code refers to a source code in a qml format;
[0142] The saving unit 604 is specifically used to save the qml source code as a qml file, and the qml file refers to a file in the qml format.
[0143] In some optional implementations, the analysis unit 602 is further used to determine control properties of at least some controls in the control tree using the analysis program, wherein the control properties are used to determine associations between controls, and the control properties are also used to determine the control tree.
[0144] In some optional implementations, the analysis unit 602 is specifically configured to use the analysis program to call the introspection capability of QObject to obtain the control properties of at least some controls in the control tree.
[0145] Those skilled in the art should understand that Figure 6 The implementation functions of each unit in the file generation device shown can be understood by referring to the relevant description of the aforementioned file generation method. Figure 6 The functions of each unit in the document generation device shown may be implemented by a program running on a processor, or may be implemented by a specific logic circuit.
[0146] Figure 7 700 is a schematic structural diagram of an electronic device 700 provided in an embodiment of the present application. The electronic device may be a mobile phone, a tablet computer, a wearable device, etc. Figure 7 The electronic device 700 shown includes a processor 710, which can call and run a computer program from a memory to implement the method in the embodiment of the present application.
[0147] Alternatively, if Figure 7 As shown, the electronic device 700 may further include a memory 720. The processor 710 may call and run a computer program from the memory 720 to implement the method in the embodiment of the present application.
[0148] Alternatively, if Figure 7 As shown, the electronic device 700 may further include a transceiver 730, and the processor 710 may control the transceiver 730 to communicate with other devices, specifically, may send information or data to other devices, or receive information or data sent by other devices.
[0149] Figure 8 It is a schematic structural diagram of the chip of an embodiment of the present application. Figure 8 The chip 800 shown includes a processor 810, which can call and run a computer program from a memory to implement the method in the embodiment of the present application.
[0150] Alternatively, if Figure 8 As shown, the chip 800 may further include a memory 820. The processor 810 may call and run a computer program from the memory 820 to implement the method in the embodiment of the present application.
[0151] The memory 820 may be a separate device independent of the processor 810 , or may be integrated into the processor 810 .
[0152] Optionally, the chip 800 may further include an input interface 830. The processor 810 may control the input interface 830 to communicate with other devices or chips, and specifically, may obtain information or data sent by other devices or chips.
[0153] Optionally, the chip 800 may further include an output interface 840. The processor 810 may control the output interface 840 to communicate with other devices or chips, and specifically, may output information or data to other devices or chips.
[0154] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0155] It should be understood that the processor of the embodiment of the present application may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by the hardware integrated logic circuit or software instructions in the processor. The above processor can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor are combined and performed. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, and other mature storage media in the art. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0156] It can be understood that the memory in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0157] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program.
[0158] Optionally, the computer-readable storage medium can be applied to the network device in the embodiments of the present application, and the computer program enables the computer to execute the corresponding processes implemented by the network device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0159] Optionally, the computer-readable storage medium can be applied to the mobile terminal / terminal device in the embodiments of the present application, and when the computer program is executed by the processor, it implements the corresponding processes implemented by the mobile terminal / terminal device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0160] An embodiment of the present application also provides a computer program product, including computer program instructions.
[0161] Optionally, the computer program product can be applied to the network device in the embodiments of the present application, and when the computer program instructions are executed by the processor, the corresponding processes implemented by the network device in the various methods of the embodiments of the present application are implemented. For the sake of brevity, they are not repeated here.
[0162] Optionally, the computer program product can be applied to the mobile terminal / terminal device in the embodiments of the present application, and when the computer program instructions are executed by the processor, the corresponding processes implemented by the mobile terminal / terminal device in the various methods of the embodiments of the present application are implemented, which will not be repeated here for the sake of brevity.
[0163] The embodiment of the present application also provides a computer program.
[0164] Optionally, the computer program can be applied to the network device in the embodiments of the present application. When the computer program runs on a computer, the computer executes the corresponding processes implemented by the network device in the various methods in the embodiments of the present application. For the sake of brevity, they are not described here.
[0165] Optionally, the computer program can be applied to the mobile terminal / terminal device in the embodiments of the present application. When the computer program is run on a computer, the computer executes the corresponding processes implemented by the mobile terminal / terminal device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0166] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0167] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0168] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0169] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0170] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0171] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0172] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A file generation method, characterized in that: The method comprises: loading an analysis program into a target application, the analysis program comprising a dynamic link library; Analyzing the target application using the analysis program to obtain a control tree of the target application, wherein the analysis program is further used to determine control properties of at least some controls in the control tree, wherein the control properties are used to determine associations between the controls, and the control properties are also used to determine the control tree; A target source code is generated based on the control tree, and the target source code is saved as a target file, wherein the target source code refers to a source code in a target format, and the target file refers to a file in a target format.
2. The method according to claim 1, characterized in that The step of loading the analysis program into the target application comprises: The dynamic link library of the analysis program is loaded into the target application.
3. The method according to claim 2, characterized in that Loading the dynamic link library of the analysis program into the target application comprises: Use a debugger to load the dynamic link library of the analysis program into the target application; or, The dynamic link library of the analysis program is loaded into the target application using a dynamic linker.
4. The method according to claim 1, characterized in that: The step of analyzing the target application using the analysis program to obtain a control tree of the target application includes: Using the analysis program to search for at least one window displayed by the target application, each window in the at least one window corresponds to a control tree; The analysis program is used to determine a control tree corresponding to the at least one window.
5. The method according to claim 4, characterized in that The target application is a running Qt Quick application.
6. The method according to claim 5, characterized in that The step of using the analysis program to search for at least one window displayed by the target application program includes: Using the analysis program to call the allWindows method to find all windows displayed by the target application; or, Using the analysis program to call the topLevelWindows method to find all top-level windows displayed by the target application; or, Using the analysis program to call the focusWindow method to find the focus window displayed by the target application; The allWindows method, the topLevelWindows method, and the focusWindow method are methods provided by the Qt Quick application.
7. The method according to claim 5, characterized in that The using the analysis program to determine the control tree corresponding to the at least one window includes: Using the analysis program to call the contentItem method of QQuickWindow to traverse the at least one window, and obtain a corresponding Qt Quick control tree, wherein the Qt Quick control tree includes at least one Qt Quick control; The contentItem method of the QQuickWindow is a method provided by the Qt Quick application.
8. The method according to claim 4, characterized in that The target application is a running QWidget application.
9. The method according to claim 8, characterized in that The step of using the analysis program to search for at least one window displayed by the target application program includes: Using the analysis program to call the allWidgets method to search for all windows displayed by the target application; or, Using the analysis program to call the topLevelWidgets method to find all top-level windows displayed by the target application; or, Using the analysis program to call the focusWidget method to find the focus window displayed by the target application; Among them, the allWidgets method, the topLevelWidgets method and the focusWidget method are methods provided by the QWidget application.
10. The method according to claim 8, characterized in that The using the analysis program to determine the control tree corresponding to the at least one window includes: Using the analysis program to call the children method of QObject to traverse the at least one window, and obtain a corresponding QWidget control tree, wherein the QWidget control tree includes at least one QWidget control; wherein the children method of QObject is a method provided by the QWidget application; Based on the control mapping relationship table, the QWidget control tree is mapped to a Qt Quick control tree, wherein the control mapping relationship table is used to express a mapping relationship between a QWidget control and a Qt Quick control.
11. The method according to claim 7 or 10, characterized in that: The step of generating a target source code based on the control tree and saving the target source code as a target file includes: Translate the Qt Quick control tree to obtain a qml source code, where the qml source code refers to a source code in a qml format; The qml source code is saved as a qml file, where the qml file refers to a file in the qml format.
12. The method according to any one of claims 1 to 10, characterized in that The method further comprises: The analysis program is used to determine the control properties of at least some controls in the control tree, wherein the control properties are used to determine the association relationship between controls, and the control properties are also used to determine the control tree.
13. The method according to claim 5, characterized in that The using the analysis program to determine the control properties of at least some controls in the control tree includes: The analysis program is used to call the introspection capability of QObject to obtain the control properties of at least part of the controls in the control tree.
14. An electronic device, characterized in that: include: A processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory to execute the method according to any one of claims 1 to 13.
15. A computer-readable storage medium, characterized in that: The device stores a computer program, which implements the method according to any one of claims 1 to 13 when executed by a processor.
Citation Information
Patent Citations
Application program debugging method based on Android system, and terminal equipment
CN105630665A
Application program interface layout code generation method and device and electronic equipment
CN112799669A