Arc-shaped sliding menu tool drawing method and arc-shaped sliding menu tool
By combining the custom Model class and the ListView control, the elliptical formula is used to calculate the sliding trajectory and rotation trajectory, which solves the problem that the arc sliding menu effect is not smooth in the QT environment, and realizes the smooth operation of the arc sliding menu tool, which is suitable for radio interfaces. .
Patent Information
- Application Number
- CN202410755569.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-09-06
AI Technical Summary
In the QT environment, it is difficult to achieve the arc-shaped sliding menu effect with existing technology. The direct map sliding path is horizontal or vertical, causing the effect to be unsmooth. QPainter drawing is based on the CPU, causing lags.
The custom Model class inherits QAbstractListModel, registers it in Qml, combines the ListView control with the custom proxy view, sets the coordinates and rotation attributes, and uses the ellipse formula to calculate the sliding trajectory and rotation trajectory to form an arc sliding menu.
The Model-ListView architecture is used to separate data from the display interface. ListView is a GPU control that enables smooth and silky operation of arc menu tools. It is suitable for radio interfaces and operates smoothly and stably when dynamically collecting and deleting channels.
Smart Images

Figure CN118605871A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of GUI application development, and in particular to a method for drawing an arc sliding menu tool and an arc sliding menu tool. Background Art
[0002] Currently in the QT environment, the existing technology usually uses textures to create an arc-shaped sliding menu. However, since the sliding path in this way is horizontal or vertical, direct textures cannot achieve the arc-shaped sliding effect. The second method is to draw in QPainter. Since QPainter drawing is based on the CPU, the effect is jittery and not smooth, which cannot meet the friendly experience of human-computer interaction. Summary of the invention
[0003] The purpose of the present invention is to solve the technical problems existing in the background technology and to provide a method for drawing an arc-shaped sliding menu tool, comprising the following steps:
[0004] Customize the Model class, which inherits QAbstractListModel;
[0005] Register the custom Model class in Qml;
[0006] Use the ListView control to set the custom Model class as the Model of the ListView.
[0007] Customize the ListView's agent and set it as a custom agent to form a custom agent view that can slide dynamically horizontally;
[0008] Set the coordinate and rotation properties of the custom proxy view to form an arc-shaped sliding menu tool.
[0009] Furthermore, "customizing the Model class, which inherits QAbstractListModel" also includes the following steps:
[0010] Create C++Model;
[0011] Set custom data types;
[0012] Store custom data through Qt::UserRole.
[0013] Furthermore, the custom data types include station frequency band data, station type data, and button type data.
[0014] Furthermore, "registering the custom Model class in Qml" also includes the following steps:
[0015] Implement Qml's call to the custom Model class through QmlRegisterType.
[0016] Furthermore, the custom agent uses Button in Qml as the base class of the agent.
[0017] Furthermore, “setting the coordinate attributes and rotation attributes of the custom proxy view to form an arc-shaped sliding menu tool” includes the following steps:
[0018] The activity track of the custom proxy view is calculated according to the ellipse formula to form an arc display window;
[0019] The rotation track of the custom proxy view is calculated according to the ellipse formula so that the proxy view slides along the arc display window.
[0020] Furthermore, the present invention also provides an arc-shaped sliding menu tool, which is drawn by an arc-shaped sliding menu tool drawing method of the present invention.
[0021] Furthermore, an arc-shaped sliding menu tool is applied to the radio interface.
[0022] Compared with the prior art, the present invention has the following beneficial technical effects: the present invention separates data from the display interface through Model-ListView. Model is mainly used to communicate with data and provide an interface for ListView control. ListView control can index data through Model and display it on the interface. It can be understood that ListView is a GPU-based control. Therefore, the arc menu tool drawn by the present invention has a smooth and smooth menu tool interface when operating, no lag, and stable operation. When used in the radio interface, channels can also be dynamically collected and deleted. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 is a flow chart of the steps of the present invention;
[0024] Figure 2 This is a partial code diagram of the custom Model class;
[0025] Figure 3 Part of the code diagram for registering a custom Model class in Qml;
[0026] Figure 4 Part of the code diagram for setting the custom Model as the Model of ListView;
[0027] Figure 5 Part of the code diagram for setting the ListView's agent to a custom agent;
[0028] Figure 6 A partial code diagram for calculating the coordinates and rotation angle of any point on the arc according to the ellipse formula;
[0029] Figure 7 Part of the code diagram to achieve smooth scrolling of the button on the arc;
[0030] Figure 8 Part of the code diagram for extending the custom RadioButtionItem;
[0031] Fig. 9 The present invention is a schematic diagram of the trajectory of each point obtained according to the ellipse formula;
[0032] Fig.10 The figure is a schematic diagram of calculating the rotation angle of each point according to trigonometric functions in the present invention. DETAILED DESCRIPTION
[0033] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of this application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0035] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0036] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0037] like Figure 1-Figure 8 As shown, the present invention proposes a method for drawing an arc-shaped sliding menu tool. The menu tool operates smoothly without lag. When used in a radio interface, channels can be dynamically added to favorites and deleted. The operation is smooth and silky. The menu uses an MVC architecture and specifically includes the following steps:
[0038] S1: Custom Model class, which inherits QAbstractListModel;
[0039] S2: Register the custom Model class in Qml;
[0040] S3: Use the ListView control to set the custom Model class as the Model of ListView;
[0041] S4: Customize the ListView's agent and set the agent to the custom agent to form a custom agent view that can slide dynamically horizontally;
[0042] S5: Set the coordinate attributes and rotation attributes of the custom proxy view to form an arc-shaped sliding menu tool.
[0043] It can be understood that the present invention separates data from the display interface through Model-ListView. Model is mainly used to communicate with data and provide an interface for ListView control. ListView control can index data through Model and display it on the interface. In this embodiment, Qt can implement the use of C++Model based on steps S1 and S2 to achieve the division of labor and cooperation between C++ and Qml. Further, in this embodiment, the communication between ListView control and the custom Model class of the present invention can be realized based on step S3. Specifically, ListView control is used to display single-column list data, that is, to visualize the data indexed by the custom Model class in the form of a list. It should be noted that ListView is Based on the GPU control, the display interface can run smoothly and stably. Further, based on step S4, the present invention can customize the ListView agent and set the agent to a custom type of agent. It can be understood that in the Model-ListView structure, the agent function allows users to customize the interface display and editing method of data. Based on the above steps, the user can use the custom agent to form a custom agent view that can slide horizontally dynamically, that is, a one-dimensional list that can slide horizontally dynamically. At this time, the coordinate attributes and rotation attributes of the agent view can be customized to form an arc-shaped sliding menu tool. As an implementation method of the present invention, the custom agent of the present invention uses Button in Qml as the base class of the agent, and the agent supports some additional attributes such as icons and text display.
[0044] Furthermore, in this embodiment, step S1 also includes the following steps:
[0045] S11: Create C++Model;
[0046] S12: Set custom data;
[0047] S13: Storing custom data through Qt::UserRole.
[0048] In this embodiment, the custom data includes platform frequency band data, platform type data and button type data. The platform frequency band data is used to display the corresponding platform frequency band in the custom proxy view, the platform type data is used to display the corresponding platform type in the custom proxy view, and the button type data is used to display the corresponding operations in the custom proxy view, such as dynamically adding / deleting / favoriting the channel list, etc. Furthermore, this embodiment stores custom data through Qt::UserRole to avoid conflicts with other custom roles, making the model more flexible and extensible.
[0049] Furthermore, in this embodiment, S2 also includes the following steps:
[0050] S21: Implement Qml's call to the custom Model class through QmlRegisterType.
[0051] Furthermore, in this embodiment, S5 also includes the following steps:
[0052] S51: calculating the activity trajectory of the custom proxy view according to the ellipse formula to form an arc display window;
[0053] S52: Calculate a rotation trajectory of the custom proxy view according to an ellipse formula, so that the proxy view slides along the arc-shaped display window.
[0054] Based on the above steps, users can calculate the coordinates and rotation angle of any point on the proxy view arc using the ellipse formula according to their needs. By combining the above steps, the present invention can achieve smooth scrolling of the button on the arc. Furthermore, users can also expand the customized RadioButtionItem to achieve the saving and deletion of data corresponding to the button.
[0055] Furthermore, the present invention also provides an arc sliding menu tool, which is drawn by an arc sliding menu tool drawing method of the present invention, and the arc sliding menu tool is applied to a radio interface.
[0056] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the scope of protection of the invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on these embodiments, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in this field can still combine, add, delete or make other adjustments to the features in the various embodiments of the present invention according to the circumstances without conflict, without making creative work, so as to obtain different other technical solutions that do not deviate from the concept of the present invention in essence, and these technical solutions also belong to the scope of protection of the present invention.
Claims
1. A method for drawing an arc-shaped sliding menu tool, characterized in that: The steps include: Customize the Model class, which inherits QAbstractListModel; Register the custom Model class in Qml; Use the ListView control to set the custom Model class as the Model of the ListView. Customize the ListView's agent and set it as a custom agent to form a custom agent view that can slide dynamically horizontally; Set the coordinate and rotation properties of the custom proxy view to form an arc-shaped sliding menu tool.
2. The method for drawing an arc-shaped sliding menu tool according to claim 1, characterized in that: The "custom Model class, which inherits QAbstractListModel" also includes the following steps: Create C++Model; Set custom data types; The custom data is stored through Qt::UserRole.
3. The method for drawing an arc-shaped sliding menu tool according to claim 2, characterized in that: The custom data types include station frequency band data, station type data, and button type data.
4. The method for drawing an arc-shaped sliding menu tool according to claim 1, characterized in that: The "registering the custom Model class in Qml" also includes the following steps: Implement Qml's call to the custom Model class through QmlRegisterType.
5. The method for drawing an arc-shaped sliding menu tool according to claim 1, characterized in that: The custom agent uses Button in Qml as the base class of the agent.
6. The method for drawing an arc-shaped sliding menu tool according to claim 1, characterized in that: "Setting the coordinate properties and rotation properties of the custom proxy view to form an arc-shaped sliding menu tool" includes the following steps: The activity track of the custom proxy view is calculated according to the ellipse formula to form an arc display window; The rotation track of the custom proxy view is calculated according to the ellipse formula, so that the proxy view slides along the arc-shaped display window.
7. An arc-shaped sliding menu tool, characterized in that: Drawn by any of the arc-shaped sliding menu tool drawing methods described above.
8. The arc-shaped sliding menu tool according to claim 7, characterized in that: The arc-shaped sliding menu tool is applied to a radio interface.
Citation Information
Patent Citations
An optimization method for customizing diversified combination controls based on a UI
CN109828806A
Design method of arc-shaped sliding control based on WPF
CN114265536A
Defining and generating a viewtype for a base model
US20060136482A1
