PDA

View Full Version : Declarate global parameters



Dark_Tower
11th December 2006, 13:45
Hi, I need to change some code from an internal method of Qt. I would like that it could access to an integer value and a file path saved in QString or in char string. How do you think that could be better to declare both parameters? As global variables, maybe? The problem is that I don't remember how to declare them and asign/consult the value.... Could you help me, please? Thanks.

wysota
11th December 2006, 15:12
What is the method? Is it virtual?

Dark_Tower
11th December 2006, 15:37
What is the method? Is it virtual?

Is the internal method "addImage" from the file "qprintengine_pdf.cpp". The only way to change the code is by modifying the source file and rebuilding Qt. So, I need some global parameters...

Dark_Tower
11th December 2006, 17:11
Hi again, let's see if I explain it a bit better. I need to pass two variables (one integer and one string) to the internal Qt method which I can't change its header. I've thought declaring global variables with extern but I dont' know if it would work. Another solution could be with some internal cache of Qt (like QPixmapCache) application-wide but I don't know if it exists. Could you suggest me something, please? I don't mind if it's a "dirty" solution because it's just a temporal fix ;)

wysota
11th December 2006, 17:26
If you want a dirty solution, then simply copy and rename the whole class (or method, or a group of them) and make needed changes directly in that copy. You can then do with functions whatever you like. Just remember to call your changed version instead of Qt's aftrerwards.

Dark_Tower
11th December 2006, 17:46
Yes wysota I had thought in that solution. The problem is that the method is not directly called but there's a bit trace before: QPainter -> QPrinter -> ??? -> addImage

wysota
11th December 2006, 18:03
So make another flow. I understand you want to print to pdf and change the compression of images. First thing I would try is to download and check against snapshots of Qt4.3. As far as I know Trolltech planned to extend support for generating PDFs in Qt4.3 - maybe the part you want is already implemented.

If that fails, then make your own PDF generator based on something else. I think you just need to implement your own paint engine which you can then feed to QPainter.

Dark_Tower
11th December 2006, 19:01
Yes wysota I want to change the compression level. I will check the snapshots of Qt4.3. Thanks for the help.