Method for creating a modal dialog box with rounded corners based on embedded system
By setting modules and event loop mechanisms in custom modal windows, the rounded corner effect and full modal properties of dialog boxes in embedded systems are realized, and the existing technology cannot realize rounded corner and modal properties in embedded systems are solved. The problem improves the aesthetics of the interface and user interaction.
Patent Information
- Application Number
- CN202410614246.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-17
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-05-17
AI Technical Summary
In embedded systems, the rounded corner effects and modal properties of the dialog box cannot be directly implemented, and the existing technology cannot meet user needs.
ModalWidget is set through a custom modal window, inherit the QWidget function of Qt, set the rounded border, and achieve full modal effect through event loops and filter mechanisms. Set the attributes to top and close, and display different styles according to the dialog box type. .
The rounded corner effect and full modal properties of the dialog box are implemented in the embedded system to ensure the mandatory nature of user interaction and the aesthetics of interface.
Smart Images

Figure CN118444914B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of dialog box design, in particular to a method for creating a modal dialog box with rounded corner effect based on an embedded system. Background Art
[0002] In a graphical user interface, it is often necessary to pop up a dialog box to display information to the user or obtain user input response when necessary. The style of the dialog box can be a rectangular border or a rounded border; the modal attribute of the dialog box can be modal or non-modal; in general interface design, rounded borders are usually used for the beauty of the interface; and for the modal attribute, it depends on whether forced user interaction is required for confirmation. For example, to empty the Recycle Bin, a modal attribute is required, but to set the volume, a modal attribute is not required.
[0003] In Qt's interface design, the rounded corner effect and modal properties of the dialog box in the desktop system can be achieved directly by setting the properties without much operation; but in the embedded system, it is impossible to directly set the modal properties to achieve the rounded corner effect, because the class library provided by Qt does not yet have the function of a modal dialog box with rounded corners on the embedded platform, so it is impossible to directly set the rounded corner effect and modal properties of the dialog box based on the embedded system;
[0004] Existing technologies can no longer meet people's needs at this stage. Based on the current situation, it is urgent to improve existing technologies. Summary of the invention
[0005] The object of the present invention is to provide a method for creating a modal dialog box with rounded corners based on an embedded system, so as to solve the problems raised in the above background technology.
[0006] The present invention provides the following technical solution: a method for creating a modal dialog box with rounded corners based on an embedded system, the specific steps comprising:
[0007] Step S100: customizing the modal window setting module ModalWidget, setting the main window in the Qt program as the parent window of the modal window setting module ModalWidget, and setting the border style to a rounded border;
[0008] Preferably, the modal window setting module ModalWidget can inherit the functional characteristics of the atomic module QWidget of the Qt user interface when customized, and can receive mouse and keyboard events from the window system.
[0009] Step S200: the modal window setting module ModalWidget implements the event loop through the event loop interface exec of the event loop module QEventLoop, intercepting operations except screen input events; wherein, the loop interface exec is used to process all events of this thread;
[0010] Preferably, step S200 allows only the screen button to be operated as an input event, and all key operations in the oscilloscope will not be responded to.
[0011] Step S300: rewrite the filter event, intercept the screen input events outside the current window through the event filter mechanism, and only operate on the input events of the current window to achieve a full modal effect;
[0012] Preferably, step S300 only allows input event operations of the current window, and does not allow screen input event operations of the parent window.
[0013] Step S400: Setting the properties of the window to be top-level and to be destroyed when closed;
[0014] Preferably, step S400 sets the top attribute so that the priority of the window is at the highest level among all windows and will not be blocked by other windows;
[0015] Setting the destroy-on-close property blocks the user from operating applications other than this window when the window pops up; when the user responds to the window, they only need to close it, and the window will be automatically destroyed, and the modal effect will disappear.
[0016] Step S500: Setting the type of the modal dialog box: "error", "information", "inquiry", and implementing different styles according to the type of the dialog box; wherein,
[0017] The "Error" type is used to remind the user that an error has occurred and requires the user to confirm and troubleshoot the error;
[0018] The "information" type is used to display information to the user;
[0019] The "ask" type is used to remind the user whether they need to select the next step;
[0020] Preferably, the specific steps of setting the type of the modal dialog box in step S500 are: passing the type as a parameter, and also passing the text to be displayed, and when the dialog box pops up, different types of dialog boxes are displayed according to the passed-in parameters.
[0021] Step S600: The user selects the “OK” or “Cancel” option in the dialog box, closes the dialog box and exits the full modal effect.
[0022] The present invention has the following beneficial effects:
[0023] The present invention can realize direct setting of a dialog box as a full-modal attribute with a rounded corner effect in an embedded system. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a schematic diagram of the flow structure of the specific steps of the present invention;
[0025] Figure 2 The interface diagram of the modal dialog box of the present invention is of type "error";
[0026] Figure 3 The interface diagram of the modal dialog box of the present invention is of the type "information";
[0027] Figure 4 The interface diagram of the modal dialog box of the present invention is of the type of "inquiry";
[0028] Figure 5 This is an interface diagram of the dialog box of the present invention with a full modal effect. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in the field of the present invention without creative work are within the scope of protection of the present invention.
[0030] refer to Figure 1 The present invention provides the following technical solution: a method for creating a modal dialog box with rounded corners based on an embedded system, and the specific steps include:
[0031] Step S100: Customize the modal window setting module ModalWidget, set the main window in the Qt (cross-platform C++ graphical user interface application development framework) program as the parent window of the ModalWidget, and set the border style to a rounded border; the modal window setting module ModalWidget inherits the functional characteristics of the atomic module QWidget of the Qt user interface, can receive mouse, keyboard and other events from the window system, and draw its own representation on the screen;
[0032] In this embodiment, a modal window setting module ModalWidget is designed according to the characteristics of Qt and C++, and the module is used by instantiating the modal window setting module object. ModalWidget implements the basic functions of the dialog box in the interface design by inheriting QWidget, and on this basis, uses a custom mechanism to implement full modal functions and style settings: ModalWidget sets a rounded border in the style sheet and specifies the corresponding main window as the parent window. When creating an object, the parent window is passed in by calling the constructor, and then the parent window is passed into QWidget through the initialization list, so that a dialog box with a rounded corner effect can be displayed in an embedded system.
[0033] Step S200: ModalWidget implements event loop through the event loop interface exec of the event loop module QEventLoop, intercepting other operations except screen input events; wherein, all events of this thread can be processed through the loop interface exec;
[0034] In this embodiment, the blocking type of ModalWidget is set to intercept other events except screen input events, and all key operations in the oscilloscope will not be responded to; when the dialog box is displayed, the event loop interface exec is used; when the dialog box is closed, the event loop interface exec is exited. In this embodiment, refer to Figure 5 After executing step S200, only the screen buttons are allowed to be operated as input events, and other key operations will not be responded to.
[0035] Step S300: rewrite the filter event, intercept the screen input events outside the current window through the event filter mechanism, and only operate the input events of the current window to achieve a full modal effect;
[0036] In this embodiment, Qt's event filter mechanism is used to intercept input events outside the dialog area. Figure 5 After executing step S300, only the up and down buttons of "Time Base" and "Displacement" can be used as input event operations of this window, and screen input events outside this window will be blocked. For example, "System" in the parent window does not allow input operations;
[0037] In this embodiment, the full modal effect setting is implemented through steps S200 and S300, wherein step S200 implements the shielding of key events except screen input events through the interface exec of QEventLoop; step S300 shields screen input events outside this window by rewriting filter events, for example, the parent window cannot input data.
[0038] Step S400: Setting the properties of the window to be top-level and to be destroyed when closed;
[0039] In this embodiment, after setting the top attribute, the priority of this window is at the highest level of all windows and will not be blocked by other windows, thus avoiding the situation where the modal effect cannot be achieved due to being blocked by other windows. Setting the close-means-destroy attribute can block the user's operations on applications other than this window when this window pops up. When the user responds to this window, he only needs to close this window, and this window will be automatically destroyed and the modal effect will disappear, thus meeting the design requirements of the modal dialog box.
[0040] Step S500: Setting the type of the modal dialog box: "error", "information", "inquiry", and implementing different styles according to the type of the dialog box;
[0041] In this embodiment, step S500 sets different types of dialog boxes. In different usage scenarios, different parameters can be entered to select the type of dialog box. Specifically, the type is passed in as a parameter, and the text to be displayed is also passed in. When the dialog box pops up, different types of dialog boxes are displayed according to the passed in parameters.
[0042] In this embodiment, reference Figure 2 The "Error" type of the modal dialog box is used to remind the user that an error has occurred and requires the user to confirm and then troubleshoot the error; refer to Figure 3 , the "information" type of modal dialog box is used to display information to the user; refer to Figure 4 The "ask" type of the modal dialog box is used to remind the user whether they need to select the next step.
[0043] Step S600: the user selects the "OK" or "Cancel" option in the dialog box, closes the dialog box and exits the full modal effect;
[0044] In this embodiment, after the user selects an option in the dialog box, according to the design requirements of the dialog box, it is necessary to close the dialog box first and exit the modal effect at the same time, and then perform the next operation according to the user's selection.
[0045] refer to Figure 4In this embodiment, the option selection of the dialog box is actually the user clicking the "OK" or "Cancel" button, using Qt's signal slot mechanism to respond to the user's click operation; wherein, the signal slot is a new feature of Qt based on C++ syntax, which can realize communication between objects and form a certain cause and effect relationship. For example, when the "OK" or "Cancel" button detects that it has been clicked, it will send a signal. If an object is interested in this signal, this object will use the connection function to bind the signal to be processed to one of its own slot functions to process this signal; that is, when the signal is sent, the connected slot function will be automatically called, similar to the observer mode; therefore, using this feature in the slot function of ModalWidget, when the "OK" or "Cancel" button detects that it has been clicked, the dialog box of the "OK" or "Cancel" option will be closed first, and then the option selected by the user will be returned to the calling ModalWidget, and the operation will continue according to the user's choice.
[0046] In this embodiment, when the dialog box is closed, according to the close-and-destroy property, the system will enter the destructor of ModalWidget. The destructor is automatically executed by the system when the object ends its life cycle (such as the function where the object is located has been called). Therefore, the close-and-destroy property is set here. After the user makes an option selection, the dialog box is closed in the slot function. When the dialog box disappears, it will automatically enter the destructor to release itself. In the destructor, the exec interface of QEventLoop is exited, and the dialog box of the current option is closed under the action of the destructor, and the full modal effect is exited.
[0047] refer to Figure 5 , as an embodiment of the present invention, Figure 5 In the interface, both the parent window and the child window have rounded borders, and these borders with rounded corners can be directly set to full modal properties in the embedded system.
[0048] Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments, or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for creating a modal dialog box with rounded corners based on an embedded system, characterized in that: The specific steps include: Step S100: customizing the modal window setting module ModalWidget, setting the main window in the Qt program as the parent window of the modal window setting module ModalWidget, and setting the border style to a rounded border; The modal window setting module ModalWidget can inherit the functional characteristics of the atomic module QWidget of the Qt user interface when customized, and can receive mouse and keyboard events from the window system; The modal window setting module ModalWidget sets a rounded border in the style sheet, and when specifying the corresponding main window as the parent window, passes the parent window in by calling the constructor, and then passes the parent window into the atomic module QWidget through the initialization list, and finally displays a dialog box with a rounded corner effect in the embedded system; Step S200: The modal window setting module ModalWidget implements the event loop through the event loop interface exec of the event loop module QEventLoop, intercepting operations other than screen input events; only screen buttons are allowed to be operated as input events, and all key operations in the oscilloscope will not be responded to; wherein, The loop interface exec is used to process all events of this thread; when the dialog box is displayed, the event loop interface exec is used; when the dialog box is closed, the event loop interface exec is exited; Step S300: rewrite the filter event, intercept the screen input events outside the current window through the event filter mechanism, and only operate the input events of the current window to achieve a full modal effect; only allow the input event operation of the current window, and do not allow the screen input event operation of the parent window; Step S400: Setting the properties of the window to be top-level and to be destroyed when closed; Step S500: Set the type of modal dialog box: "error", "information", "inquiry", and implement different styles according to the type of dialog box; The "Error" type is used to remind the user that an error has occurred and requires the user to confirm and troubleshoot the error; The "information" type is used to display information to the user; The "ask" type is used to remind the user whether they need to select the next step; Step S600: The user selects the "OK" or "Cancel" option in the dialog box, closes the dialog box and exits the full modal effect.
2. The method for creating a modal dialog box with rounded corners based on an embedded system according to claim 1, characterized in that: Step S400 sets the top attribute so that the priority of this window is at the highest level among all windows and will not be blocked by other windows; Setting the destroy-on-close property blocks the user from operating applications other than this window when the window pops up; when the user responds to the window, they only need to close it, and the window will be automatically destroyed, and the modal effect will disappear.
3. The method for creating a modal dialog box with rounded corners based on an embedded system according to claim 1, characterized in that: The specific steps of setting the type of the modal dialog box in step S500 are: passing the type as a parameter, and also passing the text to be displayed, and when the dialog box pops up, different types of dialog boxes are displayed according to the passed-in parameters.
4. The method for creating a modal dialog box with rounded corners based on an embedded system according to claim 1, characterized in that: In step S600, after the user selects an option in the dialog box, the dialog box needs to be closed first according to the design requirements of the dialog box, and the modal effect needs to be exited at the same time, and then the next operation is performed according to the user's selection.
5. The method for creating a modal dialog box with rounded corners based on an embedded system according to claim 1, characterized in that: Step S600 responds to the user's click operation of selecting the "OK" or "Cancel" option through Qt's signal slot mechanism before closing the dialog box; wherein, the signal slot is a feature of Qt based on C++ syntax, which can realize communication between objects.
