PDA

View Full Version : Reporting in Qt4



darkadept
2nd March 2007, 20:27
Has anyone had any success with printing good looking reports in Qt4?

I've tried NCReports but their Qt4 version only compiles to a command-line version and did not work either. Also the report designer is in Qt3 only which doesn't help me.

I've tried OpenRPT as well and have had no luck getting it working either.

I originally was trying to work with a self-generated HTML report and pumped that into a QTextDocument but printing is so limited that I can't do the formatting I want.

So if you have any info or help I would love to hear it.
Thanks

Jimmy2775
2nd March 2007, 23:09
I looked into the same thing about 6 months ago. The problem with most of the 3rd party tools I found was that none of them could work across different platforms, and this was a requirement.

I ended up doing what you had mentioned: generating HTML and cramming it into a QTextDocument. This works pretty well for quick development, but I was annoyed by the lack of control I had over pagination, headers/footers, and other elements that make for good reporting.

The best solution, I think, is to manually paginate your report and paint it directly to the printer. I haven't done this myself so I can't tell you much, but there is a very good example in C++ GUI Programming with Qt 4 by Jasmin Blanchette and Mark Summerfield. Essentially it looks as though a QPainter is instantiated with a QPrinter being passed into the constructor, and then you draw the text to the painter. The problem here is that it seems to require quite a lot of effort to develop reports this way.

Perhaps with some time and ambition someone can develop a decent Qt reporting API.

darkadept
2nd March 2007, 23:15
Yeah, It looks like we stepped through the same hoops. I have that book and have seen that example. I think i'll take a closer look at it. I think I might just have to bite the bullet and code my own HTML/XML report generator. If I do I'll definitely post it here, but of course time is in such short supply.

Jimmy2775
2nd March 2007, 23:22
Yes, time is always in short supply. It's likely that I'll have to write something similar in the next year, so if you're successful (or not) please post back here or send me an email via my account here - I am curious to know how it goes for you.

Jimmy

Brandybuck
3rd March 2007, 03:20
I have heard a rumour that a new Qt report engine will soon be on the market in the next couple of weeks.

darkadept
3rd March 2007, 15:28
Really? Definitely post here with the info when it comes out. Is there a place where we can see some details about it or do we have to wait? :rolleyes:

I don't think Jimmy and me are the only ones waiting for a good reporting engine. :D

prepoc
4th March 2007, 10:29
Has anyone tried kugar from koffice? There seems to be a non KDE version.

http://docs.kde.org/development/en/koffice/kugar/prog-using-widget.html

darkadept
4th March 2007, 16:02
I was about to reply "kugar is kde only!" but hey, you're right. There does seem to be some classes for crossplatform. Do you know if there are more detailed instructions on using these classes on windows or apart from kde?

I'm going to keep digging. At least I have more hope than when I started all this. :p

darkadept
5th March 2007, 16:21
I've been looking at the Kugar classes from Koffice 1.6.2 and seeing if I can port them from Qt3 to Qt4. I don't know much about Qt3 and porting to Qt4 so I think I'm stuck on that for now. I guess I'll go back to seeing if I can build my own. (or waiting for Brandybuck to cough up some details) Maybe I'll use the kugar classes as an inspiration.

Brandybuck
6th March 2007, 05:40
...(or waiting for Brandybuck to cough up some details)...
I really don't know much more. As I said, it's only a rumour. I was given the same maddening sliver of hope I passed on to you.

p.s. I am working on my own printing classes for Qt, but they will not be geared towards reports.

coralbird
23rd March 2007, 00:49
Really? Definitely post here with the info when it comes out. Is there a place where we can see some details about it or do we have to wait? :rolleyes:

I don't think Jimmy and me are the only ones waiting for a good reporting engine. :D

Sure,now I am looking for a way to make report forum just like windows office's style .:mad:

GreyGeek
10th May 2007, 21:20
I've been looking at the Kugar classes from Koffice 1.6.2 and seeing if I can port them from Qt3 to Qt4. I don't know much about Qt3 and porting to Qt4 so I think I'm stuck on that for now. I guess I'll go back to seeing if I can build my own. (or waiting for Brandybuck to cough up some details) Maybe I'll use the kugar classes as an inspiration.

When I rummaged through the code in OpenRpt I noticed two things:
1) They had ported it from Qt3 to Qt4
2) Several of the critical features are in Qt3 and no suitable widget exists in Qt4 without a LOT of recoding and workarounds for features that were in Qt3 but not in Qt4.

This is probably why they pushed it out as a GPL app. Hoping to get the community to complete the Qt3->Qt4 conversion.

ocascante
10th May 2007, 21:40
Try report manager from sourceforge.net..... it works so well!!!

croftj
11th May 2007, 15:52
The Qcj data libraries have the startings of this. They, sadly, have trouble crossing page boundaries when printing. I have plans, and they are now at least sort of ready, to have them do their own formatting for the printer. This will be down the road.

The QcjData classes are a live project which I use a lot and so it's developement and improvements will be on going. You can find them at

http://www.linuxlots.com/~qcj

You can email me directly if you (and I'm sure you will) have any questions on the report classes. joe@croftj.net

bayazee
8th August 2007, 18:37
hi
after some googling i found this :
http://www.eclipse.org/birt/phoenix

i need to generate some reports in my apps and i'm looking for a good tool.i think birt can be suitable.