Page setting and data dynamic display and editing method based on Qt

By combining QMetaObject and the expression evaluation engine with QItemDelegate, we have achieved page setup and dynamic data display and editing based on Qt, which solves the problems of insufficient flexibility and user customization capabilities in existing technologies, and improves development efficiency and user experience.

CN121070352APending Publication Date: 2025-12-05深圳市斯维尔科技股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511090978.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-05
Publication Date
2025-12-05

AI Technical Summary

Technical Problem

In existing BIM software for construction cost estimation, the QTreeView control lacks flexibility and versatility in dynamic data display and editing, making it difficult to support dynamic display and editing under complex conditions. Furthermore, its insufficient user customization capabilities result in low development efficiency.

Method used

By dynamically obtaining object properties through QMetaObject, combined with the expression evaluation engine and QItemDelegate delegate mechanism, dynamic display and editing of data can be achieved. It supports editing methods for multiple data types, and user-defined display logic can be implemented through page settings configuration files.

Benefits of technology

It improves development efficiency, supports dynamic display and editing under complex logic conditions, enhances user experience and software localization capabilities, and simplifies the development process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121070352A_ABST
    Figure CN121070352A_ABST
Patent Text Reader

Abstract

The invention discloses a Qt-based page setting and data dynamic display and editing method, which comprises the following steps of: 1, initializing a QStandItemModel, and storing and binding data; step 2, page setting and loading; step 3, performing expression evaluation and dynamic display; 4, a QItemDelegate derivation class is created, and data editing is carried out on the QItemDelegate derivation class; and 5, performing row control and column control. The invention relates to the technical field of construction engineering, and can solve the technical problems in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of construction engineering, and particularly relates to a page setting and data dynamic display and editing method based on Qt. BACKGROUND

[0002] In the construction engineering cost BIM software, the display and editing of data is one of the core functions. Users need to view and modify complex engineering data, such as cost list, material parameters, etc. through the graphical interface. These data are usually presented in table or tree structure, and the software is required to dynamically adjust the display content (such as text, color, font, etc.) according to user needs and provide efficient editing functions.

[0003] The existing interface development frameworks (such as Qt, MFC, JavaFX, etc.) provide basic support for data display and editing, but developers usually need to manually write a large amount of code to realize the dynamic display and conditional formatting of data, which is low in development efficiency, and the interface is difficult to adapt to the individual needs of different users or regions.

[0004] In the Qt framework, QTreeView is a commonly used control for displaying multi-column data in tree structure, and QStandardItemModel and QItemDelegate can be combined to realize the display and editing of data. The existing scheme for realizing data display and editing based on Qt QTreeView includes the following steps:

[0005] 1. Data binding and display: store data through QStandardItemModel, and bind the model directly to QTreeView to display data content. Developers usually need to manually set the display format (such as text, number, enumeration, etc.) of each column.

[0006] 2. Data editing: implement cell editing function through QItemDelegate or its derived classes. For example, set QSpinBox for integer type data and QLineEdit for string type.

[0007] 3. Conditional formatting: some implementation schemes realize simple conditional formatting through hard coding, such as setting background color according to cell value, but usually limited to single condition, unable to support evaluation of complex expressions or multi-condition combination.

[0008] 4. Interface configuration: in the existing scheme, interface configuration (such as table header, display style) is usually predefined by developers in the code, and users cannot directly adjust the display logic through the interface.

[0009] The traditional QTreeView implementation scheme often requires developers to write special-purpose code for each data type and display requirement when dealing with dynamic display and editing under complex conditions, lacking universality and flexibility. For example, existing solutions usually cannot achieve condition-based dynamic display (such as changing the color or font of a cell according to the data value) through simple configuration, and it is also difficult to support user-defined interface settings, which limits the localization ability and user experience of the software.

[0010] The traditional QTreeView implementation scheme has the following technical problems:

[0011] 1. Lack of flexible expression evaluation mechanism: The expression evaluation in existing technologies is mainly used for data operations (such as addition, subtraction, multiplication, and division), and cannot dynamically judge the result according to complex logical conditions (such as multiple operators and function combinations) and apply it to display or editing.

[0012] 2. Display logic is complex and not universal: When implementing condition-based dynamic display (such as displaying text, color, and font according to multiple condition combinations), existing solutions require developers to write a large amount of custom code, lacking a universal configuration mechanism.

[0013] 3. Single editing method: The existing QItemDelegate implementation only supports editing of basic data types (such as integers and strings), and it is difficult to support complex data types or condition-based editing logic.

[0014] 4. Insufficient user customization ability: In existing technologies, interface display and editing logic are usually hard-coded by developers, and users cannot achieve personalized settings through a configuration interface, limiting the localization ability and user experience of the software.

[0015] 5. Low development efficiency: Developers need to write special-purpose code for each data type and display requirement, increasing development and maintenance costs.

[0016] Therefore, it is necessary to provide a Qt-based page setting and data dynamic display and editing method to solve the above technical problems. SUMMARY

[0017] The purpose of the present application is to provide a Qt-based page setting and data dynamic display and editing method to solve the above technical problems.

[0018] The present application is implemented as follows:

[0019] A Qt-based page setting and data dynamic display and editing method, comprising the following steps:

[0020] Step 1: Initialize QStandardItemModel, data storage and binding;

[0021] Step 2: Page setting loading;

[0022] Step 3: Expression evaluation and dynamic display;

[0023] Step 4: Create QItemDelegate derived class for data editing;

[0024] Step 5: Row control and column control.

[0025] The step 1 includes the following sub-steps:

[0026] Step 1.1: Store data in QStandardItemModel, QStandardItemModel only processes one column of data;

[0027] Step 1.2: Each piece of data is bound to the object's property through QStandardItem, and the object's property information is dynamically obtained through QMetaObject;

[0028] Step 1.3: QStandardItemModel is used as a data model and passed to QTreeView for display.

[0029] In step 1.2, the object's property information includes property name and value.

[0030] The step 2 includes the following sub-steps:

[0031] Step 2.1: The system loads the user-defined page setting configuration file;

[0032] Step 2.2: According to the page setting information in the page setting configuration file, parse the table header and display conditions, and dynamically create the table header of QTreeView.

[0033] In step 2.1, the format of the page setting configuration file is JSON or XML; the page setting configuration file contains table header information, display conditions, and editing agent settings.

[0034] In step 2.2, the table header of QTreeView includes column name and width.

[0035] The step 3 includes the following sub-steps:

[0036] Step 3.1: The system parses the expression of the page setting in the page setting configuration file, calls the expression evaluation engine in Qt, and calculates the result of the expression through the expression evaluation engine;

[0037] Step 3.2: According to the calculation result of the expression, dynamically adjust the display content of QTreeView cell;

[0038] Step 3.3: Display the content through single-condition or multi-condition combination logic.

[0039] In step 3.2, the display content of the QTreeView cell includes:

[0040] ① Text content: display the original value or the calculated value based on the condition;

[0041] ② Font: set the font type, size, and boldness;

[0042] ③ Text color and background color: set the foreground color and background color according to the condition;

[0043] ④ Icon: display the icon associated with the condition.

[0044] The step 4 includes the following sub-steps:

[0045] Step 4.1: Derive a class from QItemDelegate to implement editing delegates for multiple data types;

[0046] In step 4.1, the data types include integer, floating-point number, string, enumeration, and boolean value;

[0047] Step 4.2: Each editing delegate provides corresponding editing controls according to the data type;

[0048] In step 4.2, the editing controls include QSpinBox, QComboBox, and QCheckBox;

[0049] Step 4.3: The user edits the data, and through QMetaObject, dynamically modifies the properties of the object, refreshes the QTreeView, displays the updated data, and ensures that the data updates are reflected in the model in real time.

[0050] In step 5, row control: when the data of a certain row meets the set condition, all QTreeView cells in that row adopt a unified display format according to the set condition; column control: each column can set a default display format and support dynamic format based on conditions.

[0051] Compared with the prior art, the present application has the following beneficial effects:

[0052] 1、The application is based on QMetaObject to dynamically obtain object properties, combined with expression evaluation logic, to realize dynamic display and editing of complex conditions of data in QTreeView, and provides a general expression evaluation mechanism for complex expressions, supports complex logical conditions, so as to dynamically judge results according to combinations of multiple operators, functions and parameters and apply them to data display, solves the problem of lack of flexible expression evaluation mechanism in the prior art, simplifies the development process, developers do not need to write special code for each data type, and development efficiency is greatly improved.

[0053] 2、The application supports multiple data type editing modes through a QItemDelegate derived class, including integer, floating point number, string, enumeration and boolean value, improves the universality and flexibility of editing, and solves the problem of single editing mode in the prior art.

[0054] 3、The application supports condition-based dynamic display format through row control and column control mechanism, the display format includes text, font, color, background color, icon, supports flexible combination of text, font, color, background color and icon, solves the problem of complex and non-universal display logic in the prior art.

[0055] 4、The page setting of the application allows users to customize table headers, display logic and editing mode through a page setting configuration file, adapts to the individual needs of different regions and users, improves the localization ability and user experience of the software, and solves the problem of insufficient user customization ability in the prior art. BRIEF DESCRIPTION OF DRAWINGS

[0056] Figure 1 is a flowchart of the page setting and data dynamic display and editing method based on Qt of the application. DETAILED DESCRIPTION

[0057] The application will be further described below in combination with the drawings and specific embodiments.

[0058] The terms involved in the application are explained as follows:

[0059] Qt: A cross-platform C++ application development framework for building graphical user interfaces (GUI) and non-GUI applications.

[0060] QMetaObject: A meta-object in the Qt framework, used to dynamically obtain object properties, methods and signals, supporting runtime reflection mechanism.

[0061] QTreeView: A control in the Qt framework, used to display data in a tree structure, supporting multi-column display and editing.

[0062] QStandardItemModel: A data model class in the Qt framework used to store and manage data in QTreeView.

[0063] QItemDelegate: A delegate class in the Qt framework used to customize the display and editing of cells in QTreeView.

[0064] Expression evaluation: Calculate the result based on the input expression (including operators, functions, parameters) to dynamically control data display or behavior.

[0065] The invention dynamically obtains the properties of the object through QMetaObject, combines the expression evaluation engine and QItemDelegate proxy mechanism, realizes the dynamic display and editing of data, and supports user-defined display logic through page setting function.

[0066] Please refer to the attached Figure 1 A method for page setting and dynamic display and editing of data based on Qt, comprising the following steps:

[0067] Step 1: Initialize QStandardItemModel, data storage and binding.

[0068] The step 1 includes the following sub-steps:

[0069] Step 1.1: Store data in QStandardItemModel, QStandardItemModel only processes one column of data to improve efficiency.

[0070] Further, QAbstractItemModel can also be used instead of QStandardItemModel, which can be used for custom data storage and access logic, suitable for more complex data structures, but the implementation cost will be relatively high.

[0071] Step 1.2: Each piece of data is bound to the object's property through QStandardItem, and the object's property information is dynamically obtained through QMetaObject.

[0072] In the step 1.2, the object's property information includes property name and value.

[0073] Step 1.3: QStandardItemModel as a data model, passed to QTreeView for display.

[0074] Step 2: Page setting loading.

[0075] The step 2 includes the following sub-steps:

[0076] Step 2.1: The system loads the user-defined page setting configuration file.

[0077] In step 2.1, the page setting configuration file is in JSON or XML format.

[0078] In step 2.1, the page setting configuration file contains table header information, display conditions, and editor agent settings.

[0079] Step 2.2: According to the page setting information in the page setting configuration file, parse the table header and display conditions, and dynamically create the table header of QTreeView.

[0080] In step 2.2, the table header of QTreeView includes column name, width, and other information.

[0081] Step 3: Expression evaluation and dynamic display.

[0082] Step 3 includes the following sub-steps:

[0083] Step 3.1: The system parses the expression of the page setting in the page setting configuration file (for example: "value>100&&type==‘steel’"), calls the expression evaluation engine in Qt, and calculates the result of the expression through the expression evaluation engine.

[0084] Further, various complex expression evaluations can be implemented using a script language (such as Python or Lua) embedded parser, which is more flexible but may increase system complexity and performance overhead.

[0085] Step 3.2: According to the calculation result of the expression, dynamically adjust the display content of the QTreeView cell.

[0086] In step 3.2, the display content of the QTreeView cell includes:

[0087] ① Text content: display the original value or the calculated value based on the condition.

[0088] ② Font: set font type, size, bold, etc.

[0089] ③ Text color and background color: set the foreground and background color according to the condition, for example, display red background color when the condition is met.

[0090] ④ Icon: display the icon associated with the condition.

[0091] Step 3.3: Display the content through single condition or multi-condition combination logic. For example, when a cell meets multiple conditions at the same time, the display content is the combined result (such as text content + background color, etc.).

[0092] Step 4: Create a QItemDelegate-derived class for data editing.

[0093] The step 4 includes the following sub-steps:

[0094] Step 4.1: Implement multiple data type editing delegates by inheriting QItemDelegate-derived class.

[0095] In the step 4.1, the data types include integer (int), floating point number (double), string (QString), enumeration (enum), Boolean (bool), etc.

[0096] Step 4.2: Each editing delegate provides corresponding editing controls according to the data type.

[0097] In the step 4.2, the editing controls include QSpinBox, QComboBox, QCheckBox, etc.

[0098] Step 4.3: User edits data, and dynamically modifies the properties of the object through QMetaObject, refreshes QTreeView, displays the updated data, and ensures that the data update is reflected in the model in real time.

[0099] Further, QStyledItemDelegate can also be used instead of QItemDelegate-derived class to support more complex custom styles, but more code may be needed to implement the editing function.

[0100] Step 5: Row control and column control.

[0101] In the step 5, row control: when certain row data meets the set conditions (for example: whole row highlighting, etc.), all QTreeView cells in the row adopt a unified display format according to the set conditions; column control: each column can set a default display format (for example: font, color, etc.), and supports condition-based dynamic format (for example: color change when the value is greater than a certain threshold, etc.).

[0102] The above is only a preferred embodiment of the present application, and is not used to limit the protection scope of the application, therefore, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for page setup and dynamic data display and editing based on Qt, characterized by: The method comprises the following steps: Step 1: initialize QStandardItemModel, data storage and binding; Step 2: page setting loading; Step 3: expression evaluation and dynamic display; Step 4: create a QItemDelegate derived class for data editing; Step 5: row control and column control.

2. The Qt-based page setting and data dynamic display and editing method according to claim 1, characterized in that: The step 1 comprises the following sub-steps: Step 1.1: store data in QStandardItemModel, QStandardItemModel only processes one column of data; Step 1.2: each piece of data is bound to the object's attribute through QStandardItem, and the object's attribute information is dynamically obtained through QMetaObject; Step 1.3: QStandardItemModel is used as a data model and is passed to QTreeView for display.

3. The method for Qt-based page setting and dynamic display and editing of data according to claim 2, characterized in that: In the step 1.2, the object's attribute information includes attribute name and value.

4. The method for Qt-based page setting and dynamic display and editing of data according to claim 1, characterized in that: The step 2 comprises the following sub-steps: Step 2.1: the system loads the user-defined page setting configuration file; Step 2.2: according to the page setting information in the page setting configuration file, the table header and display conditions are parsed, and the table header of QTreeView is dynamically created.

5. The method for Qt-based page setting and dynamic display and editing of data according to claim 4, characterized in that: In the step 2.1, the format of the page setting configuration file is JSON or XML; the page setting configuration file contains table header information, display conditions and editing agent settings.

6. The method for Qt-based page setting and dynamic display and editing of data according to claim 4, characterized in that: In the step 2.2, the table header of QTreeView includes column name and width.

7. The method for Qt-based page setting and dynamic display and editing of data according to claim 1, characterized in that: The step 3 comprises the following sub-steps: Step 3.1: the system parses the expression of the page setting in the page setting configuration file, calls the expression evaluation engine in Qt, and calculates the result of the expression through the expression evaluation engine; Step 3.2: according to the calculation result of the expression, the display content of QTreeView cell is dynamically adjusted; Step 3.3: display the content through single condition or multi-condition combination logic.

8. The method for Qt-based page setting and dynamic display and editing of data according to claim 7, characterized in that: In the step 3.2, the display content of QTreeView cell includes: ① text content: display the original value or the calculated value based on the condition; ② font: set font type, size and boldness; ③ text color and background color: set foreground color and background color according to the condition; ④ icon: display the icon associated with the condition.

9. The method for Qt-based page setting and dynamic display and editing of data according to claim 1, characterized in that: The step 4 comprises the following sub-steps: Step 4.1: a QItemDelegate derived class is created to implement editing agents for multiple data types; In step 4.1, the data types include integer, floating point number, string, enumeration and boolean value; Step 4.2: each editing agent provides corresponding editing controls according to the data type; In step 4.2, the editing controls include QSpinBox, QComboBox and QCheckBox; Step 4.3: the user edits the data, dynamically modifies the object's attribute through QMetaObject, refreshes QTreeView, displays the updated data, and ensures that the data update is reflected in the model in real time.

10. The method for Qt-based page setting and dynamic display and editing of data according to claim 1, characterized in that: The step 5 is row control: when certain row data meets the set condition, all QTreeView cells in the row adopt the unified display format according to the set condition; Column control: each column can set the default display format, and supports the dynamic format based on the condition.