File box printing method based on Qt

Through the Qt-based file box printing method, the functions and libraries of the QT framework are integrated, and the problems of complex and single functions of traditional printing terminal technology are solved, efficient and convenient printing operations are achieved, and printing efficiency and user experience are improved.

CN119473178APending Publication Date: 2025-02-18HANGZHOU ZHONGZHU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411371785.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

Traditional printing terminal technology has problems such as complex operation, unfriendly interface, single functions, and difficulty in domestic adaptation, which cannot meet users' needs for flexible, efficient and convenient printing.

Method used

Using the Qt-based file box printing method, the efficient and convenient operation of the printing terminal is achieved by integrating the rich functions and libraries of the QT framework, improving the printing efficiency and optimizing the user experience.

Benefits of technology

It realizes efficient and convenient operation of the printing terminal, improves printing efficiency, optimizes the user experience, and meets users' needs for flexible, efficient and convenient printing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473178A_ABST
    Figure CN119473178A_ABST
Patent Text Reader

Abstract

The invention discloses a file box printing method based on Qt, and the method comprises the following steps: S1, building serial port communication; s2, setting a printing template; s3, extracting printing data; the step S3 comprises the following steps: step S31, selecting a printing template; s32, data needing to be printed are imported; step S33, traversing the primitives; step S34, acquiring vertex coordinates of the primitives; s35, converting the primitives into pictures, and then converting the pictures into primitive dot matrix data; and S36, after the pixel traversal is finished, combining all pixel dot matrix data. The file box printing method based on the Qt is convenient to use, efficient and convenient operation of the printing terminal is achieved by integrating rich functions and libraries of the QT frame, the printing efficiency is improved, and the user experience is optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of file box printing, and in particular to a file box printing method based on Qt. Background Art

[0002] With the rapid development of information technology, printing equipment plays an increasingly important role in archival work. However, traditional printing terminal technology often has problems such as complex operation, unfriendly interface, single function, and difficulty in localization adaptation, which cannot meet users' needs for flexible, efficient and convenient printing.

[0003] Based on the above situation, the present invention proposes a file box printing method based on Qt, which can effectively solve the above problems. Summary of the invention

[0004] The object of the present invention is to provide a Qt-based file box printing method. The Qt-based file box printing method of the present invention is easy to use, and by integrating the rich functions and libraries of the QT framework, the efficient and convenient operation of the printing terminal is realized, the printing efficiency is improved, and the user experience is optimized.

[0005] The present invention is achieved through the following technical solutions:

[0006] A Qt-based file box printing method comprises the following steps:

[0007] Step S1: Establish serial port communication;

[0008] Step S2: Setting a printing template;

[0009] Step S3: extracting print data;

[0010] The step S3 comprises the following steps:

[0011] Step S31: Select a printing template;

[0012] Step S32: importing the data to be printed;

[0013] Step S33: traverse the primitives;

[0014] Step S34: Obtaining the coordinates of the vertex of the primitive;

[0015] Step S35: converting the image element into a picture, and then converting the picture into image element dot matrix data;

[0016] Step S36: After the pixel traversal is completed, all the primitive dot matrix data are merged.

[0017] The object of the present invention is to provide a Qt-based file box printing method. The Qt-based file box printing method of the present invention is easy to use, and by integrating the rich functions and libraries of the QT framework, the efficient and convenient operation of the printing terminal is realized, the printing efficiency is improved, and the user experience is optimized.

[0018] Preferably, the step S2 comprises the following steps:

[0019] Step S21: open a template or create a new template;

[0020] Step S22: Enter the template editing page;

[0021] Step S23: Select one of template attribute modification, adding a new element, selecting an element, or modifying an element;

[0022] Step S24: After completing the template editing, choose whether to save it to the database.

[0023] Preferably, the step S1 comprises the following steps:

[0024] Step S11: traverse serial port information;

[0025] Step S12: Determine whether the serial port description is consistent with that of the lower computer. If so, proceed to step S13; if not, return to step S11;

[0026] Step S13: Determine whether the serial port is available, if so, proceed to step S14, if not, return to step S11;

[0027] Step S14: Add it to the list of available serial ports;

[0028] Step S15: traverse the list of available serial ports,

[0029] Step S16: Determine whether the port number of the available serial port is equal to the configured port number, if so, proceed to step S17, if not, return to step S15;

[0030] Step S17: Open the serial port.

[0031] Preferably, the step S34 includes the following steps:

[0032] Step S341: dividing the printing primitive into a plurality of first printing areas S0 vertically according to the inkjet area height;

[0033] Step S342: The segmented areas are numbered starting from 0 from top to bottom and traversed.

[0034] Step S343: dividing the first printing area S0 into a plurality of second printing areas S1 in a transverse direction according to the inkjet area width;

[0035] Step S344: the image width is set to W, and the pixels inside the first printing area S0 are traversed horizontally: the number of the first printing area S0 is modulo 2, if the remainder is 0, then traverse from 0 to W-1, that is, from left to right;

[0036] If the remainder is 1, traverse from W-1 to 0, that is, from right to left;

[0037] Step S345: traverse the pixels inside the second printing area S1 from bottom to top, calculate the value of the bit data according to the RGB value of the pixel, if the RGB value is less than 255, record it as 1, otherwise record it as 0, and finally write it into the bit data array;

[0038] Step S346: Convert the bit array into a byte array, effectively reducing the amount of transmitted data.

[0039] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0040] 1. The file box printing method provided by the present invention makes full use of the cross-platform characteristics of Qt, so that the printing method can run on different operating systems, which perfectly fits the current localization trend.

[0041] 2. The module editing method provided by the present invention is simple to operate and has a smooth and stable interface.

[0042] 3. The method for extracting print data provided by the present invention can quickly obtain print primitive coordinates and images, effectively filter blank data, and improve the efficiency of extracting and transmitting print data.

[0043] 4. The serial port communication establishment method provided by the present invention does not require configuration of baud rate, check bit, data bit, stop bit and flow control, and does not even need to care about the serial port number, which can effectively reduce the problem of communication failure caused by serial port configuration. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 A schematic block diagram of the process of setting a printing template according to the present invention;

[0045] Figure 2 This is a schematic block diagram of the process of extracting print data according to the present invention;

[0046] Figure 3 The present invention is a flowchart of establishing serial communication. DETAILED DESCRIPTION

[0047] In order to enable those skilled in the art to better understand the technical solution of the present invention, the preferred implementation scheme of the present invention is described below in conjunction with specific embodiments. However, it should be understood that the drawings are only used for exemplary description and cannot be understood as a limitation on this patent. In order to better illustrate this embodiment, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product. For those skilled in the art, it is understandable that some well-known structures and their descriptions in the drawings may be omitted. The positional relationship described in the drawings is only for exemplary description and cannot be understood as a limitation on this patent.

[0048] Embodiment 1:

[0049] like Figures 1 to 3 As shown, the present invention provides a Qt-based file box printing method, comprising the following steps:

[0050] Step S1: Establish serial port communication;

[0051] Step S2: Setting a printing template;

[0052] Step S3: extracting print data;

[0053] The step S3 comprises the following steps:

[0054] Step S31: Select a printing template;

[0055] Step S32: importing the data to be printed;

[0056] Step S33: traverse the primitives;

[0057] Step S34: Obtaining the coordinates of the vertex of the primitive;

[0058] Step S35: converting the image element into a picture, and then converting the picture into image element dot matrix data;

[0059] Step S36: After the pixel traversal is completed, all the primitive dot matrix data are merged.

[0060] Embodiment 2:

[0061] like Figures 1 to 3 As shown, the present invention provides a Qt-based file box printing method, comprising the following steps:

[0062] Step S1: Establish serial port communication;

[0063] Step S2: Setting a printing template;

[0064] Use Qt's QGraphics library, including views (QGraphicsView), scenes (QGraphicsScene) and graphics elements (QGraphicsItem). The structural relationship is: graphics elements depend on scenes, and scenes depend on views.

[0065] The implementation steps are:

[0066] 1. Create a base class BaseItem that inherits the QGraphicsItem class, rewrite the mousePressEvent, mouseReleaseEvent, mouseMoveEvent and itemChange functions to implement the selection, movement and scaling functions of the element, and create an itemId attribute as the unique identifier of the element;

[0067] 2. Create a specific graphic element class that inherits the BaseItem class (such as line, rectangle, circle, text, rich text, picture, etc.), rewrite the type function to distinguish the type, and rewrite the paint function to realize the drawing of the graphic element shape;

[0068] 3. Create a view class that inherits the QGraphicsView class, override the wheelEvent function to implement wheel zooming and page turning, and override the paintEvent function to draw auxiliary lines when the element is selected and moved.

[0069] Especially in the printing image processing stage, the coordinates of each printing unit can be directly obtained without traversing the entire printing format, which can greatly improve the speed of image processing.

[0070] Step S3: extracting print data;

[0071] The step S3 comprises the following steps:

[0072] Step S31: Select a printing template;

[0073] Step S32: importing the data to be printed;

[0074] Step S33: traverse the primitives;

[0075] Step S34: Obtaining the coordinates of the vertex of the primitive;

[0076] Step S35: converting the image element into a picture, and then converting the picture into image element dot matrix data;

[0077] Step S36: After the pixel traversal is completed, all the primitive dot matrix data are merged.

[0078] The step S2 comprises the following steps:

[0079] Step S21: open a template or create a new template;

[0080] Step S22: Enter the template editing page;

[0081] Step S23: Select one of template attribute modification, adding a new element, selecting an element, or modifying an element;

[0082] Step S24: After completing the template editing, choose whether to save it to the database.

[0083] Further, in another embodiment, the step S1 includes the following steps:

[0084] Step S11: traverse serial port information;

[0085] Step S12: Determine whether the serial port description is consistent with that of the lower computer. If so, proceed to step S13; if not, return to step S11;

[0086] Step S13: Determine whether the serial port is available, if so, proceed to step S14, if not, return to step S11;

[0087] Step S14: Add it to the list of available serial ports;

[0088] Step S15: traverse the list of available serial ports,

[0089] Step S16: Determine whether the port number of the available serial port is equal to the configured port number, if so, proceed to step S17, if not, return to step S15;

[0090] Step S17: Open the serial port.

[0091] The serial communication is established as follows:

[0092] 1. Use Qt's QSerialPortInfo to get the serial port list;

[0093] 2. Use the description function of QSerialPortInfo to obtain the serial port description information. The serial port whose description information is consistent with the serial port of the lower computer is marked as an available serial port.

[0094] 3. QSerialPort sets QSerialPortInfo and executes the open function to complete the serial port connection.

[0095] Further, in another embodiment, the step S34 includes the following steps:

[0096] Step S341: dividing the printing primitive into a plurality of first printing areas S0 vertically according to the inkjet area height;

[0097] Step S342: The segmented areas are numbered starting from 0 from top to bottom and traversed.

[0098] Step S343: dividing the first printing area S0 into a plurality of second printing areas S1 in a transverse direction according to the inkjet area width;

[0099] Step S344: the image width is set to W, and the pixels inside the first printing area S0 are traversed horizontally: the number of the first printing area S0 is modulo 2, if the remainder is 0, then traverse from 0 to W-1, that is, from left to right;

[0100] If the remainder is 1, traverse from W-1 to 0, that is, from right to left;

[0101] Step S345: traverse the pixels inside the second printing area S1 from bottom to top, calculate the value of the bit data according to the RGB value of the pixel, if the RGB value is less than 255, record it as 1, otherwise record it as 0, and finally write it into the bit data array;

[0102] Step S346: Convert the bit array into a byte array, effectively reducing the amount of transmitted data.

[0103] According to the description and drawings of the present invention, those skilled in the art can easily manufacture or use the Qt-based file box printing method of the present invention, and can produce the positive effects recorded in the present invention.

[0104] Unless otherwise specified, in the present invention, the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicating orientation or positional relationships are based on the orientation or positional relationships shown in the drawings, which are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, the terms describing the orientation or positional relationship in the present invention are only used for illustrative purposes and cannot be understood as limitations on this patent. For ordinary technicians in this field, the specific meanings of the above terms can be understood in conjunction with the drawings and according to specific circumstances.

[0105] Unless otherwise clearly specified and limited, in the present invention, the terms "disposed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be directly connected, or indirectly connected through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0106] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any simple modification or equivalent change made to the above embodiment based on the technical essence of the present invention shall fall within the protection scope of the present invention.

Claims

1. A file box printing method based on Qt, characterized in that: The following steps are included: Step S1: Establish serial port communication; Step S2: Setting a printing template; Step S3: extracting print data; The step S3 comprises the following steps: Step S31: Select a printing template; Step S32: importing data to be printed; Step S33: traverse the primitives; Step S34: Obtaining the coordinates of the vertex of the primitive; Step S35: converting the image element into a picture, and then converting the picture into image element dot matrix data; Step S36: After the pixel traversal is completed, all the primitive dot matrix data are merged.

2. The Qt-based file box printing method according to claim 1, characterized in that: The step S2 comprises the following steps: Step S21: open a template or create a new template; Step S22: Enter the template editing page; Step S23: Select one of template attribute modification, adding a new element, selecting an element, or modifying an element; Step S24: After completing the template editing, choose whether to save it to the database.

3. The Qt-based file box printing method according to claim 1, characterized in that: The step S1 comprises the following steps: Step S11: traverse serial port information; Step S12: Determine whether the serial port description is consistent with that of the lower computer. If so, proceed to step S13; if not, return to step S11; Step S13: Determine whether the serial port is available, if so, proceed to step S14, if not, return to step S11; Step S14: Add it to the list of available serial ports; Step S15: traverse the list of available serial ports, Step S16: Determine whether the port number of the available serial port is equal to the configured port number, if so, proceed to step S17, if not, return to step S15; Step S17: Open the serial port.

4. The Qt-based file box printing method according to claim 1, characterized in that: The step S34 comprises the following steps: Step S341: dividing the printing primitive into a plurality of first printing areas S0 vertically according to the inkjet area height; Step S342: The segmented areas are numbered starting from 0 from top to bottom and traversed. Step S343: dividing the first printing area S0 into a plurality of second printing areas S1 in a transverse direction according to the inkjet area width; Step S344: the image width is set to W, and the pixels inside the first printing area S0 are traversed horizontally: the number of the first printing area S0 is modulo 2, if the remainder is 0, then traverse from 0 to W-1, that is, from left to right; If the remainder is 1, traverse from W-1 to 0, that is, from right to left; Step S345: traverse the pixels inside the second printing area S1 from bottom to top, calculate the value of the bit data according to the RGB value of the pixel, if the RGB value is less than 255, record it as 1, otherwise record it as 0, and finally write it into the bit data array; Step S346: Convert the bit array into a byte array, effectively reducing the amount of transmitted data.