Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

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.

Inactive Publication Date: 2013-03-20
SHANGHAI SPACEFLIGHT INST OF TT&C & TELECOMM
View PDF3 Cites 26 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0006] The present invention aims to solve the problems such as high degree of module coupling and poor code readability that exist in the current Qt development process. The present invention provides a method for using a Qt-based custom control, which includes the following steps:

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Using method of custom control based on Qt
  • Using method of custom control based on Qt
  • Using method of custom control based on Qt

Examples

Experimental program
Comparison scheme
Effect test

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...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention provides a using method of a custom control based on Qt, which comprises the steps that a class in a basic class library based on the Qt is used as a parent class to derive a custom control class; the custom control class reloads the member function of the parent class or establishes a new constructor to realize self-packaging; the custom control class used as the custom control allocates space for the custom control class and calls the reloaded member function of the parent class or the constructor; and one of the Qt graphical interfaces can include a plurality of independent custom controls for match. The using method of the custom control based on the Qt provided by the invention has the advantages that the coupling degree between software modules can be effectively reduced, and meanwhile, the program code is simplified, thus being easy for maintenance; and in addition, the control can also be operated dynamically.

Description

technical field [0001] The invention relates to a Qt graphical interface development method, in particular to a Qt graphical interface development method applied in the embedded field. [0002] Background technique [0003] In the embedded field, take VxWorks as an example, under the premise of ensuring the real-time performance of the system, the requirements for more powerful humanized interface design are getting higher and higher. At present, under VxWorks, the built-in WindML graphics library component is mostly used for development, which has weak functions for graphics development such as windows and controls. Compared with other image development libraries such as WindML, Qt has the advantages of supporting multiple platforms, strong code portability, and rich graphics library functions. The combination of VxWorks and Qt can be used as a solution for the development of embedded graphical interface. [0004] Qt provides a rich class library, which is enough for the...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F9/44
Inventor 高宇史云鹏施连灯
Owner SHANGHAI SPACEFLIGHT INST OF TT&C & TELECOMM
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products