CN104298509A - qss style sheet based interface beautifying method - Google Patents
qss style sheet based interface beautifying method Download PDFInfo
- Publication number
- CN104298509A CN104298509A CN201410522840.4A CN201410522840A CN104298509A CN 104298509 A CN104298509 A CN 104298509A CN 201410522840 A CN201410522840 A CN 201410522840A CN 104298509 A CN104298509 A CN 104298509A
- Authority
- CN
- China
- Prior art keywords
- qss
- file
- style sheet
- engineering
- style
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a qss style sheet based interface beautifying method. The method comprises the following steps: S1, adding a qss file to Qt engineering, and describing the properties of each activeX through the qss file under different operation states according to the grammatical norms of the style sheet; S2, adding a qrc file to the Qt engineering, and enabling the qrc to appoint all resource files including the qss file used in the Qt engineering; S3, setting a main QT thread in a source program, and loading the property of each active under different operation states through the qss file.
Description
Technical field
The present invention relates to field of embedded technology, particularly a kind of interface beautification method based on qss style sheet.
Background technology
Qt is a cross-platform C++ application development frameworks be widely used at present.In interface development process, usually often creating a control and will carry out Beautification design to this control, when the complicated interface that exploitation one is made up of a lot of control, obviously increasing because beautifying required size of code, and same class control to beautify code all substantially identical, code redundancy is high.
Summary of the invention
The present invention is directed to prior art above shortcomings, provide a kind of interface beautification method based on qss style sheet.The present invention is achieved through the following technical solutions:
Based on an interface beautification method for qss style sheet, comprise step:
S1, in Qt engineering, add a qss file, qss file is described the attribute of each control under difference manipulation state according to the syntax gauge of style sheet;
S2, in Qt engineering, add a qrc file, all resource files comprising qss file used by Qt engineering specified by qrc file;
S3, Qt main thread is set in source program adopts qss file, load the attribute of each control under difference manipulation state.
Preferably, qss file adopts the syntax gauge of style sheet to edit, and the different conditions residing for control arranges its appearance style respectively, and the appearance style of control comprises: frame size and corner cambered, character script, background and foreground.
Preferably, the different conditions residing for control arranges its appearance style respectively and comprises:
Adopt QPushButton{...}, QPushButton:hover{...}, QPushButton:pressed{...}, respectively on button normality, mouse displacement to button, the mouse button appearance pattern that presses the button three kinds of states arranges.
Preferably, step S3 comprises: increase in the main-inlet function of Qt engineering and read function to file, the filename of qss file is read in QString string variable, then calls setStyleSheet(QString str) load the attribute of each control under difference manipulation state.
Beneficial effect of the present invention:
Adopt the interface beautification method of qss style sheet, by the function code at interface and code can being beautified separately, how to beautify without the need to being concerned about when realizing interface function, and beautify that code is unified to be included in qss file, effectively reduce the code degree of coupling.In addition, adopt style sheet to make the code that beautifies of same class control only need to write once, significantly reduce size of code, enhance code readability simultaneously.
Accompanying drawing explanation
Shown in Fig. 1 is process flow diagram of the present invention;
Shown in Fig. 2 is the process flow diagram of one embodiment of the invention.
Embodiment
Below with reference to accompanying drawing of the present invention; clear, complete description and discussion are carried out to the technical scheme in the embodiment of the present invention; obviously; as described herein is only a part of example of the present invention; it is not whole examples; based on the embodiment in the present invention, the every other embodiment that those of ordinary skill in the art obtain under the prerequisite not making creative work, all belongs to protection scope of the present invention.
For the ease of the understanding to the embodiment of the present invention, be further explained for specific embodiment below in conjunction with accompanying drawing, and each embodiment does not form the restriction to the embodiment of the present invention.
As shown in Figure 1, the invention provides a kind of interface beautification method based on qss style sheet, its process is:
First in Qt engineering, add a qss file, write qss file according to the syntax gauge of style sheet, the attribute such as outward appearance, color of various controls under difference manipulation state is described; Then in Qt engineering, add a qrc file, all resource files used by Qt engineering specified by this file, wherein just have the appointment to qss file; Finally in source program, arrange Qt main thread adopts this qss file, loads the pattern style of various controls, thus realizes beautifying the unification at interface.
Embodiment 1
In embodiment 1 shown in Fig. 2, qss style sheet method is adopted to unify to beautify to the button control in interface.Its detailed process is:
A qss file is added in Qt engineering, and adopt the syntax gauge of style sheet to edit, such as: QPushButton{...}, QPushButton:hover{...}, QPushButton:pressed{...}, respectively on button normality, mouse displacement to button, the mouse button appearance pattern that presses the button these three kinds of states arranges; In Qt engineering, add a qrc file, the qss file editted is added in qrc file; Increase in Qt engineering main-inlet function and function read to file, qss filename is read in QString string variable, then calls setStyleSheet(QString str) the pattern style of load button control.
The present invention by the function code at interface and can beautify code separately, how to beautify without the need to being concerned about when realizing interface function, and beautifies that code is unified to be included in qss file, effectively reduces the code degree of coupling.In addition, adopt style sheet to make the code that beautifies of same class control only need to write once, significantly reduce size of code, enhance code readability simultaneously.
The above; be only the present invention's preferably embodiment, but protection scope of the present invention is not limited thereto, is anyly familiar with those skilled in the art in the technical scope that the present invention discloses; the change that can expect easily or replacement, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.
Claims (4)
1., based on an interface beautification method for qss style sheet, it is characterized in that, comprise step:
S1, in Qt engineering, add a qss file, described qss file is described the attribute of each control under difference manipulation state according to the syntax gauge of style sheet;
S2, in Qt engineering, add a qrc file, all resource files comprising described qss file used by Qt engineering specified by described qrc file;
S3, Qt main thread is set in source program adopts described qss file, load the attribute of each control under difference manipulation state.
2. the interface beautification method based on qss style sheet according to claim 1, it is characterized in that, described qss file adopts the syntax gauge of style sheet to edit, different conditions residing for control arranges its appearance style respectively, and the appearance style of control comprises: frame size and corner cambered, character script, background and foreground.
3. the interface beautification method based on qss style sheet according to claim 2, is characterized in that, described different conditions residing for control arranges its appearance style respectively and comprises:
Adopt QPushButton{...}, QPushButton:hover{...}, QPushButton:pressed{...}, respectively on button normality, mouse displacement to button, the mouse button appearance pattern that presses the button three kinds of states arranges.
4. the interface beautification method based on qss style sheet according to claim 1, it is characterized in that, described step S3 comprises: increase in the main-inlet function of Qt engineering and read function to file, the filename of described qss file is read in QString string variable, then calls setStyleSheet(QString str) load the attribute of each control under difference manipulation state.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410522840.4A CN104298509A (en) | 2014-10-08 | 2014-10-08 | qss style sheet based interface beautifying method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410522840.4A CN104298509A (en) | 2014-10-08 | 2014-10-08 | qss style sheet based interface beautifying method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104298509A true CN104298509A (en) | 2015-01-21 |
Family
ID=52318252
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410522840.4A Pending CN104298509A (en) | 2014-10-08 | 2014-10-08 | qss style sheet based interface beautifying method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104298509A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109254770A (en) * | 2018-08-23 | 2019-01-22 | 深圳点猫科技有限公司 | The method and electronic equipment of custom button pattern under graphic programming platform |
CN112099792A (en) * | 2020-09-18 | 2020-12-18 | 上海逸动医学科技有限公司 | Visual UI style design method and system |
CN112506137A (en) * | 2020-11-02 | 2021-03-16 | 南通恒康数控机械股份有限公司 | Design method of control interface applied to numerical control sponge cutting machine |
CN113568609A (en) * | 2021-09-24 | 2021-10-29 | 成都中科合迅科技有限公司 | UI style editing method based on Qss style sheet |
CN113656005A (en) * | 2021-06-29 | 2021-11-16 | 杭州华橙软件技术有限公司 | Application component library construction method, application component configuration method and related device |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US4956806A (en) * | 1988-07-12 | 1990-09-11 | International Business Machines Corporation | Method and apparatus for editing source files of differing data formats using an edit tracking file |
JP2002229789A (en) * | 2001-01-30 | 2002-08-16 | Hitachi Commun Syst Inc | Program source file management method by multiple users on the same network and program source file management system |
CN102413297A (en) * | 2010-09-21 | 2012-04-11 | 康佳集团股份有限公司 | Method for realizing webpage browsing on television and television |
CN102681846A (en) * | 2012-04-26 | 2012-09-19 | 中山大学 | Embedded multimedia playing system and method |
-
2014
- 2014-10-08 CN CN201410522840.4A patent/CN104298509A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US4956806A (en) * | 1988-07-12 | 1990-09-11 | International Business Machines Corporation | Method and apparatus for editing source files of differing data formats using an edit tracking file |
JP2002229789A (en) * | 2001-01-30 | 2002-08-16 | Hitachi Commun Syst Inc | Program source file management method by multiple users on the same network and program source file management system |
CN102413297A (en) * | 2010-09-21 | 2012-04-11 | 康佳集团股份有限公司 | Method for realizing webpage browsing on television and television |
CN102681846A (en) * | 2012-04-26 | 2012-09-19 | 中山大学 | Embedded multimedia playing system and method |
Non-Patent Citations (1)
Title |
---|
MARKELY: "Qt之qss文件编写", 《HTTP://BLOG.CSDN.NET/MARKELY/ARTICLE/DETAILS/7881203》 * |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109254770A (en) * | 2018-08-23 | 2019-01-22 | 深圳点猫科技有限公司 | The method and electronic equipment of custom button pattern under graphic programming platform |
CN109254770B (en) * | 2018-08-23 | 2022-03-11 | 深圳点猫科技有限公司 | Method for customizing button style under graphical programming platform and electronic equipment |
CN112099792A (en) * | 2020-09-18 | 2020-12-18 | 上海逸动医学科技有限公司 | Visual UI style design method and system |
CN112099792B (en) * | 2020-09-18 | 2024-02-02 | 上海逸动医学科技有限公司 | Visual UI style design method and system |
CN112506137A (en) * | 2020-11-02 | 2021-03-16 | 南通恒康数控机械股份有限公司 | Design method of control interface applied to numerical control sponge cutting machine |
CN113656005A (en) * | 2021-06-29 | 2021-11-16 | 杭州华橙软件技术有限公司 | Application component library construction method, application component configuration method and related device |
CN113656005B (en) * | 2021-06-29 | 2023-11-24 | 杭州华橙软件技术有限公司 | Application component library construction method, application component configuration method and related devices |
CN113568609A (en) * | 2021-09-24 | 2021-10-29 | 成都中科合迅科技有限公司 | UI style editing method based on Qss style sheet |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104298509A (en) | qss style sheet based interface beautifying method | |
CN102981855A (en) | Template-based interface autogeneration method and system | |
CN104424338A (en) | Automatic generation device and automatic generation method for web system | |
CN103116508B (en) | A kind of general-purpose interface of SAP system and its implementation | |
CN104571026A (en) | Platform and method for establishing whole-process metallurgical manufacturing execution system | |
CN104598233A (en) | Code generation method | |
CN204990761U (en) | Picture instrument is led in thinking for economic management | |
CN103064682A (en) | Device-orientated human-computer interface configuration design method | |
CN105573764A (en) | Android application reconstruction method for smart watch | |
CN105426609A (en) | Method for automatically deleting dangling lines in PCB design | |
CN105867944A (en) | Web front-end terminal operating layer and implementing method thereof | |
CN102662962B (en) | Dynamic display method based on webpage elements | |
CN100498698C (en) | General interface design interface system and interface developing method using said system | |
CN106095821A (en) | A General Form Configuration Management Method | |
CN104834513B (en) | A kind of method and system that fully-mechanized mining working surface hydraulic support controller software automatically generates | |
CN103777998B (en) | A kind of efficient call method of built-up pattern component | |
WO2016201813A1 (en) | Dynamic layout method and system based on android | |
CN107391158B (en) | A method and device for realizing table drawing based on iDataTable encapsulation | |
CN104317590A (en) | Embedded configuration system and embedded review process configuration method | |
CN104199675A (en) | System capable of quick system development based on database parameter utilization | |
CN103135968A (en) | Intelligent display terminal system | |
CN102566993A (en) | Method and device for editing interface | |
CN106325852A (en) | Application dynamic interface customizing method | |
CN205080859U (en) | Display device's package assembly | |
CN105242921A (en) | Compatibile UI developing device and application therefor |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
EXSB | Decision made by sipo to initiate substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20150121 |