Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: Can I send LimeReport form to directly printer in Qt Console Application?  (Read 3974 times)

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Hi,
I want to create LimeReport form on GUI. But I need to send this form directly to printer (no need to show or design!) in console application.
Is this possible? I did not test now but I guess It must be possible?

Regards,
Mucip:)

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
Re: Can I send LimeReport form to directly printer in Qt Console Application?
« Reply #1 on: December 08, 2022, 06:55:54 am »
And what's trouble?
some th. like this

Code: [Select]
if (QPrinterInfo::defaultPrinter().isNull()) // no default printer in System
   return;
LimeReport::ReportEngine *m_report=new LimeReport::ReportEngine(this);
m_report->loadFromFile(path_to_template);
QPrinter *printer=new QPrinter(QPrinterInfo::defaultPrinter();
connect(m_report, &LimeReport::ReportEngine::renderFinished, printer, &QPrinter::deleteLater);
m_report->printReport(printer);

this code loads the report template from
Code: [Select]
path_to_template and send it to default system printer (if exist
after finsh the rendering created printer object will be destroyed
« Last Edit: December 08, 2022, 07:06:13 am by Subst »

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Can I send LimeReport form to directly printer in Qt Console Application?
« Reply #2 on: December 08, 2022, 09:16:07 am »
Hi,
Perfect suggestion. Thanks.  ;)

Regards,
Mucip:)

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Can I send LimeReport form to directly printer in Qt Console Application?
« Reply #3 on: December 08, 2022, 08:55:15 pm »
Hi,
I tryed but I've got error here connect statement

&QPrinter::deleteLater

No member named 'deleteLater' in 'QPrinter'

Regards,
Mucip:)

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
Re: Can I send LimeReport form to directly printer in Qt Console Application?
« Reply #4 on: December 08, 2022, 09:24:18 pm »
Oh..
QPrinter is not inherited from QObject
yep

I'll thing about how better

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
Re: Can I send LimeReport form to directly printer in Qt Console Application?
« Reply #5 on: December 09, 2022, 08:44:05 am »
Try to change appropriate part of code to

Code: [Select]
QPrinter *printer=new QPrinter(QPrinterInfo::defaultPrinter());
connect(m_report, &LimeReport::ReportEngine::renderFinished, this, [this,printer]() {
  delete printer;
  });
m_report->printReport(printer)

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Can I send LimeReport form to directly printer in Qt Console Application?
« Reply #6 on: December 11, 2022, 04:31:13 pm »
Hi,
Houstan, we have a problem... :(

As I said I want to use LimeReport (print report to printer only!) .n console application in RP4.

I created one object in main.cpp. And do everything in this object (reading serial ports, wiringpi, sending limereport file to printer etc.)

But in the begining when I create Lime report in this pbject,

m_Limereport = new LimeReport::ReportEngine(this);

I got an error in console like:

QPixmap::fromImage: QPixmap cannot be created without a QGuiApplication

What do you advice?

Regards,
Mucip:)

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
Re: Can I send LimeReport form to directly printer in Qt Console Application?
« Reply #7 on: December 11, 2022, 06:13:23 pm »
The LR is using QGraphicsScene for rendering
QGraphisScene is using QWidget in turn.
You need it :(

Also may be your are using the pixamp in report template?

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Can I send LimeReport form to directly printer in Qt Console Application?
« Reply #8 on: December 11, 2022, 07:23:29 pm »
Hi,
Yes I have picture in design unfortunatelly.
This is very bad news.
Is this mean I can not use LimeReport in Console Application?

Regards,
Mucip:)

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
Re: Can I send LimeReport form to directly printer in Qt Console Application?
« Reply #9 on: December 11, 2022, 08:01:02 pm »
QPixmap - it's the GUI class, but QImage - not.
can you using the QImage ?

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Can I send LimeReport form to directly printer in Qt Console Application?
« Reply #10 on: December 11, 2022, 09:49:31 pm »
Hi,
I do not think that I can do something about this problem. May be Arin can?...

Because the problem comes when

m_Limereport = new LimeReport::ReportEngine(this);

Arin?...

Otherwise I need to rewrite all code in Python and fpdf2... :(

But I want to use Qt and LimeReport for sure...

Regards,
Mucip:)