Using method of custom control based on Qt
A self-defined, control-like technology, applied in the direction of program control devices, etc., can solve the problems of poor code readability and high module coupling, and achieve the effect of concise program code, reduced coupling, and easy maintenance.
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0026] figure 2 In the shown embodiment 1, a custom Label control is designed and applied. The specific process is:
[0027] Use the Qlabel class that comes with Qt as the parent class to derive the label_widget class as a custom Label control, and its constructor is declared as follows:
[0028] label_widget(QWidget *parent = 0, quint16 x = 10, quint16 y = 10, quint16 w = 10, quint16 h = 10, QString lbl_text = tr(""), QString lbl_font = tr("宋体"), quint8 lbl_size = 12, bool changeble = false, QColor color_back = Qt::black, QColor color_fore = Qt::white, bool frame = true);
[0029] The functions completed by this constructor are: use the QLabel class that comes with Qt to set the background color of the Label control, and change the background color of the Label and the border color together. In order to achieve the three-dimensional effect of the border, two Labels are used to achieve it; the underlying Label is used to maintain the border Style, the top Label is used to ...
Embodiment 2
[0033] image 3 In the shown embodiment 2, a custom dynamic control is designed and applied. In addition to the fixed display interface, sometimes there are dynamic information display requirements, such as target information in the radar PPI display screen. In the past, drawing was often used to draw dynamic information, which can be realized by using methods such as XOR, texture redrawing, and full screen refresh. The disadvantage is that there are many branches in the judgment of software programming conditions, the processing is cumbersome and the screen is prone to flickering. Using Qt, the dynamic control can be realized through the custom control class, which can display the dynamic information well without being affected by other windows and without redrawing, and completely solve the problems caused by the previous method.
[0034] In order to realize the PPI display target control, the moving_widget class is generated based on QWidget, and a parameter type is added...
Embodiment 3
[0045] exist Figure 4 In the shown embodiment 3, a custom control containing multiple sub-controls is designed and applied. In Qt development, sub-windows are often superimposed on the main interface, and sometimes it is necessary to implement the mouse drag function for sub-windows without a title bar without affecting the main interface and other sub-windows. The sub-window can be realized through a custom control, and the member functions mouseMoveEvent() and mousePressEvent() of QWidget are overloaded in the custom control class, and the displacement of the control is obtained through the returned QMouseEvent event type, and then through QWidget::move( ) to move the control, the mouse can drag the sub-window.
[0046] If the window is composed of multiple child controls, each child control needs to respond to mouse down events. If the mousePressEvent() of QWidget is overloaded for each child control, it is obvious that the code repetition rate is high, and the coupling be...
PUM
Abstract
Description
Claims
Application Information
- R&D Engineer
- R&D Manager
- IP Professional
- Industry Leading Data Capabilities
- Powerful AI technology
- Patent DNA Extraction
Browse by: Latest US Patents, China's latest patents, Technical Efficacy Thesaurus, Application Domain, Technology Topic, Popular Technical Reports.
© 2024 PatSnap. All rights reserved.Legal|Privacy policy|Modern Slavery Act Transparency Statement|Sitemap|About US| Contact US: help@patsnap.com