Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FmTakeaway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shangshang.dai
FmTakeaway
Commits
892556a9
Commit
892556a9
authored
Sep 12, 2016
by
ss.dai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成打印功能(具体样式待定)
parent
077caf2a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
fmPrinter/fmPrinter.cpp
+19
-4
fmPrinter/fmPrinter.h
+1
-1
No files found.
fmPrinter/fmPrinter.cpp
View file @
892556a9
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include <QCoreApplication>
#include <QCoreApplication>
#include <QDateTime>
#include <QDateTime>
#include <QPrinter>
#include <QPrinter>
#include <QTextDocument>
FmPrinter
&
FmPrinter
::
GetInstance
()
FmPrinter
&
FmPrinter
::
GetInstance
()
{
{
...
@@ -14,7 +15,21 @@ FmPrinter &FmPrinter::GetInstance()
...
@@ -14,7 +15,21 @@ FmPrinter &FmPrinter::GetInstance()
bool
FmPrinter
::
DoPrint
(
QString
printerName
,
OrderObject
*
pData
)
bool
FmPrinter
::
DoPrint
(
QString
printerName
,
OrderObject
*
pData
)
{
{
return
_RawDataToPrinter
(
printerName
,
_GetPrintData
(
pData
));
foreach
(
QString
data
,
_GetPrintData
(
pData
))
{
if
(
!
_RawDataToPrinter
(
printerName
,
data
))
{
return
false
;
}
QPrinter
printer
;
printer
.
setPrinterName
(
printerName
);
printer
.
setPageSizeMM
(
QSizeF
(
0
,
0
));
QTextDocument
text
(
""
);
text
.
print
(
&
printer
);
}
return
true
;
}
}
bool
FmPrinter
::
TestPrint
(
QString
printerName
,
QString
data
)
bool
FmPrinter
::
TestPrint
(
QString
printerName
,
QString
data
)
...
@@ -22,16 +37,16 @@ bool FmPrinter::TestPrint(QString printerName, QString data)
...
@@ -22,16 +37,16 @@ bool FmPrinter::TestPrint(QString printerName, QString data)
return
_RawDataToPrinter
(
printerName
,
data
);
return
_RawDataToPrinter
(
printerName
,
data
);
}
}
QString
FmPrinter
::
_GetPrintData
(
OrderObject
*
pData
)
QString
List
FmPrinter
::
_GetPrintData
(
OrderObject
*
pData
)
{
{
QString
str_list
;
QString
List
str_list
;
QString
str_print
;
QString
str_print
;
QString
str_comd_list
;
QString
str_comd_list
;
QString
filePath
=
QString
(
"%1/printformat.txt"
).
arg
(
QCoreApplication
::
applicationDirPath
());
QString
filePath
=
QString
(
"%1/printformat.txt"
).
arg
(
QCoreApplication
::
applicationDirPath
());
QFile
file
(
filePath
);
QFile
file
(
filePath
);
if
(
!
file
.
open
(
QFile
::
ReadOnly
)){
if
(
!
file
.
open
(
QFile
::
ReadOnly
)){
return
QString
(
"无法打开printformat.txt!"
);
return
QString
List
(
);
}
}
for
(
int
i
=
0
;
i
<
pData
->
proList
.
count
();
i
++
)
for
(
int
i
=
0
;
i
<
pData
->
proList
.
count
();
i
++
)
{
{
...
...
fmPrinter/fmPrinter.h
View file @
892556a9
...
@@ -30,7 +30,7 @@ private:
...
@@ -30,7 +30,7 @@ private:
* 参数:[1]订单对象
* 参数:[1]订单对象
* 返回:打印数据
* 返回:打印数据
* */
* */
QString
_GetPrintData
(
OrderObject
*
pData
);
QString
List
_GetPrintData
(
OrderObject
*
pData
);
/* 功能:打印数据
/* 功能:打印数据
* 参数:[1]物理打印机名[2]信息内容
* 参数:[1]物理打印机名[2]信息内容
* 返回:打印数据
* 返回:打印数据
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment